diff --git a/app/caches/course_cache.rb b/app/caches/course_cache.rb
index f63bd4c9c..880d5938a 100644
--- a/app/caches/course_cache.rb
+++ b/app/caches/course_cache.rb
@@ -331,17 +331,18 @@ class CourseCache
key = 'course_acts:'+course_id.to_s
data = Rails.cache.read(key)
if data.nil?
- data = []
+ # data = []
course = Course.find(course_id)
- course.course_activities.each do |act|
- data << {
- :id=>act.id,
- :user_id=>act.user_id,
- :course_act_id=>act.course_act_id,
- :course_act_type=>act.course_act_type,
- :updated_at=>act.updated_at
- }
- end
+ data = course.course_activities
+ # course.course_activities.each do |act|
+ # data << {
+ # :id=>act.id,
+ # :user_id=>act.user_id,
+ # :course_act_id=>act.course_act_id,
+ # :course_act_type=>act.course_act_type,
+ # :updated_at=>act.updated_at
+ # }
+ # end
Rails.cache.write(key,data)
end
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index ceebc0b7c..6b5e3fc77 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -1159,52 +1159,22 @@ class CoursesController < ApplicationController
if params[:type].present?
case params[:type]
when "homework"
- course_activities = course_activities.select{|act|
- if act[:course_act_type] == 'HomeworkCommon'
- act
- end
- }
+ @course_activities = course_activities.where("course_act_type = 'HomeworkCommon'").includes(:course_act).order('updated_at desc')
when "news"
- #@course_activities = course_activities.where("course_act_type = 'News'").order('updated_at desc')
- course_activities = course_activities.select{|act|
- if act[:course_act_type] == 'News'
- act
- end
- }
+ @course_activities = course_activities.where("course_act_type = 'News'").includes(:course_act).order('updated_at desc')
when "message"
- #@course_activities = course_activities.where("course_act_type = 'News'").order('updated_at desc')
- course_activities = course_activities.select{|act|
- if act[:course_act_type] == 'Message'
- act
- end
- }
- @course_activities = course_activities.sort { |a,b| b[:updated_at].to_i <=> a[:updated_at].to_i}
+ @course_activities = course_activities.where("course_act_type = 'Message'").includes(:course_act).order('updated_at desc')
when "poll"
- #@course_activities = course_activities.where("course_act_type = 'News'").order('updated_at desc')
- course_activities = course_activities.select{|act|
- if act[:course_act_type] == 'Poll'
- act
- end
- }
+ @course_activities = course_activities.where("course_act_type = 'Poll'").includes(:course_act).order('updated_at desc')
when "attachment"
- #@course_activities = course_activities.where("course_act_type = 'News'").order('updated_at desc')
- course_activities = course_activities.select{|act|
- if act[:course_act_type] == 'Attachment'
- act
- end
- }
+ @course_activities = course_activities.where("course_act_type = 'Attachment'").includes(:course_act).order('updated_at desc')
when "journalsForMessage"
- #@course_activities = course_activities.where("course_act_type = 'News'").order('updated_at desc')
- course_activities = course_activities.select{|act|
- if act[:course_act_type] == 'JournalsForMessage'
- act
- end
- }
+ @course_activities = course_activities.where("course_act_type = 'JournalsForMessage'").includes(:course_act).order('updated_at desc')
else
+ @course_activities = course_activities.includes(:course_act).order('updated_at desc')
end
- @course_activities = course_activities.sort { |a,b| b[:updated_at].to_i <=> a[:updated_at].to_i}
else
- @course_activities = course_activities.sort { |a,b| b[:updated_at].to_i <=> a[:updated_at].to_i}
+ @course_activities = course_activities.includes(:course_act).order('updated_at desc')
end
@course_activities_count = @course_activities.count
@course_activities = @course_activities[@page*10..(@page+1)*10-1]
diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb
index 8ad3323f6..c979cd4d4 100644
--- a/app/views/courses/_course_activity.html.erb
+++ b/app/views/courses/_course_activity.html.erb
@@ -50,7 +50,7 @@
-<% course_activities.includes(:course_act).each do |activity| if course_activities %>
+<% course_activities.each do |activity| if course_activities %>