组织动态按更新时间排序

This commit is contained in:
huang 2016-06-07 16:02:46 +08:00
parent acf4a64e6a
commit c5bccf1adb
2 changed files with 18 additions and 18 deletions

View File

@ -105,9 +105,9 @@ class OrganizationsController < ApplicationController
end end
# 最新动态, 来自我关联的项目和课程 # 最新动态, 来自我关联的项目和课程
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', 'JournalsForMessage') 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 created_at desc limit 6;") order by updated_at desc limit 6;")
end end
render :layout => 'base_org_custom' render :layout => 'base_org_custom'
else else

View File

@ -66,52 +66,52 @@ module OrganizationsHelper
def org_user_by_type obj def org_user_by_type obj
case obj.act_type case obj.act_type
when "Message" when "Message"
user = obj.act.author obj.act.author
when "News" when "News"
user = obj.act.author obj.act.author
when "HomeworkCommon" when "HomeworkCommon"
user = obj.act.user obj.act.user
when "Issue" when "Issue"
user = obj.act.author obj.act.author
end end
end end
def org_title_by_type obj def org_title_by_type obj
case obj.act_type case obj.act_type
when "Message" when "Message"
user = obj.act.parent_id.nil? ? obj.act.subject : obj.act.parent.subject obj.act.parent_id.nil? ? obj.act.subject : obj.act.parent.subject
when "News" when "News"
user = obj.act.title obj.act.title
when "HomeworkCommon" when "HomeworkCommon"
user = obj.act.name obj.act.name
when "Issue" when "Issue"
user = obj.act.subject obj.act.subject
end end
end end
def org_content_by_type obj def org_content_by_type obj
case obj.act_type case obj.act_type
when "Message" when "Message"
user = obj.act.parent_id.nil? ? obj.act.content : obj.act.parent.content obj.act.parent_id.nil? ? obj.act.content : obj.act.parent.content
when "News" when "News"
user = obj.act.description obj.act.description
when "HomeworkCommon" when "HomeworkCommon"
user = obj.act.description obj.act.description
when "Issue" when "Issue"
user = obj.act.description obj.act.description
end end
end end
def org_time_by_type obj def org_time_by_type obj
case obj.act_type case obj.act_type
when "Message" when "Message"
time = obj.act.updated_on obj.act.updated_on
when "News" when "News"
user = obj.act.created_on obj.act.created_on
when "HomeworkCommon" when "HomeworkCommon"
user = obj.act.updated_at obj.act.updated_at
when "Issue" when "Issue"
user = obj.act.updated_on obj.act.updated_on
end end
end end