move discussion user counts to slave

closes #LA-882

Change-Id: Id6fbd028e20f3123b2c9602345069d7e4dd7e34f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/232651
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Jeremy Stanley <jeremy@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
James Williams 2020-04-02 11:12:16 -06:00
parent 8401ade33e
commit c862439baf
2 changed files with 3 additions and 3 deletions

View File

@ -65,7 +65,7 @@ module Api::V1::DiscussionTopics
root_topics = get_root_topic_data(topics, opts[:root_topic_fields])
end
if opts[:include_sections_user_count] && context
opts[:context_user_count] = context.enrollments.not_fake.active_or_pending_by_date_ignoring_access.count
opts[:context_user_count] = Shackles.activate(:slave) { context.enrollments.not_fake.active_or_pending_by_date_ignoring_access.count }
end
ActiveRecord::Associations::Preloader.new.preload(topics, [:user, :attachment, :root_topic, :context])
topics.inject([]) do |result, topic|
@ -122,7 +122,7 @@ module Api::V1::DiscussionTopics
end
if opts[:include_sections_user_count] && !topic.is_section_specific
json[:user_count] = opts[:context_user_count] || context.enrollments.not_fake.active_or_pending_by_date_ignoring_access.count
json[:user_count] = opts[:context_user_count] || Shackles.activate(:slave) { context.enrollments.not_fake.active_or_pending_by_date_ignoring_access.count }
end
if opts[:include_sections] && topic.is_section_specific

View File

@ -46,7 +46,7 @@ module Api::V1::Section
end
if includes.include?('user_count')
res['user_count'] = section.enrollments.not_fake.active_or_pending_by_date_ignoring_access.count
res['user_count'] = Shackles.activate(:slave) { section.enrollments.not_fake.active_or_pending_by_date_ignoring_access.count }
end
res