最新动态按创建时间排序

hjq_beidou
huang 9 years ago
parent 388e862241
commit 90aaaa544a

@ -107,7 +107,7 @@ class OrganizationsController < ApplicationController
if @organization.org_subfields.where(:field_type => "Compact", :hide => 0).count > 0 if @organization.org_subfields.where(:field_type => "Compact", :hide => 0).count > 0
@acts = UserActivity.find_by_sql("SELECT * FROM `user_activities` where act_type in ('HomeworkCommon', 'News', 'Message', 'Issue') and @acts = UserActivity.find_by_sql("SELECT * FROM `user_activities` where act_type in ('HomeworkCommon', 'News', 'Message', 'Issue') and
((container_type = 'Course' and container_id in (#{course_ids.join(',')})) or (container_type = 'Project' and container_id in (#{project_ids.join(',')}))) ((container_type = 'Course' and container_id in (#{course_ids.join(',')})) or (container_type = 'Project' and container_id in (#{project_ids.join(',')})))
order by updated_at desc limit 6;") order by created_at desc limit 6;")
end end
render :layout => 'base_org_custom' render :layout => 'base_org_custom'
else else
@ -273,7 +273,7 @@ class OrganizationsController < ApplicationController
course_ids = (@organization.courses.map(&:id) - shield_course_ids) << 0 course_ids = (@organization.courses.map(&:id) - shield_course_ids) << 0
@org_acts = UserActivity.find_by_sql("SELECT * FROM `user_activities` where act_type in ('HomeworkCommon', 'News', 'Message', 'Issue') and @org_acts = UserActivity.find_by_sql("SELECT * FROM `user_activities` where act_type in ('HomeworkCommon', 'News', 'Message', 'Issue') and
((container_type = 'Course' and container_id in (#{course_ids.join(',')})) or (container_type = 'Project' and container_id in (#{project_ids.join(',')}))) ((container_type = 'Course' and container_id in (#{course_ids.join(',')})) or (container_type = 'Project' and container_id in (#{project_ids.join(',')})))
order by updated_at desc limit 6;") order by created_at desc limit 6;")
respond_to do |format| respond_to do |format|
format.html{render :layout => 'base_org_custom'} format.html{render :layout => 'base_org_custom'}
format.js format.js

@ -105,13 +105,13 @@ module OrganizationsHelper
def org_time_by_type obj def org_time_by_type obj
case obj.act_type case obj.act_type
when "Message" when "Message"
obj.act.updated_on obj.act.created_on
when "News" when "News"
obj.act.created_on obj.act.created_on
when "HomeworkCommon" when "HomeworkCommon"
obj.act.updated_at obj.act.created_at
when "Issue" when "Issue"
obj.act.updated_on obj.act.created_on
end end
end end

Loading…
Cancel
Save