PERF: optimise query that gathers topic tracking state

(this query runs on the front page to figure out new and unread topics)
This commit is contained in:
Sam
2015-07-21 17:14:30 +10:00
parent 6d9674278e
commit 343e417a55
3 changed files with 77 additions and 41 deletions

View File

@ -307,7 +307,7 @@ class ApplicationController < ActionController::Base
def preload_current_user_data
store_preloaded("currentUser", MultiJson.dump(CurrentUserSerializer.new(current_user, scope: guardian, root: false)))
serializer = ActiveModel::ArraySerializer.new(TopicTrackingState.report([current_user.id]), each_serializer: TopicTrackingStateSerializer)
serializer = ActiveModel::ArraySerializer.new(TopicTrackingState.report(current_user.id), each_serializer: TopicTrackingStateSerializer)
store_preloaded("topicTrackingStates", MultiJson.dump(serializer))
end