PERF: eliminate N+1 query due to polls

This commit is contained in:
Sam
2015-05-04 16:11:04 +10:00
parent 374e7325fa
commit c3e3afcb2c
2 changed files with 17 additions and 1 deletions

View File

@ -14,6 +14,15 @@ VOTES_CUSTOM_FIELD ||= "polls-votes".freeze
after_initialize do
# PERF, avoids N+1 in serializer
TopicView.add_post_custom_fields_whitelister do |user|
POLLS_CUSTOM_FIELD
end
TopicView.add_post_custom_fields_whitelister do |user|
VOTES_CUSTOM_FIELD
end
# remove "Vote Now!" & "Show Results" links in emails
Email::Styles.register_plugin_style do |fragment|
fragment.css(".poll a.cast-votes, .poll a.toggle-results").each(&:remove)