mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: Cache serialized voters at topic view level (#28894)
This commit introduces a way to fetch the "serialized voters" for multiple polls. * Use a single query to fetch voters for all types of polls * Refactor to introduce all_serialized_voters * Cache serialized voters
This commit is contained in:
@@ -184,6 +184,7 @@ after_initialize do
|
||||
if post_with_polls.present?
|
||||
all_polls = Poll.includes(:poll_options).where(post_id: post_with_polls)
|
||||
Poll.preload!(all_polls, user_id: @user&.id)
|
||||
DiscoursePoll::Poll.preload_serialized_voters!(all_polls)
|
||||
all_polls.each do |p|
|
||||
polls[p.post_id] ||= []
|
||||
polls[p.post_id] << p
|
||||
|
||||
Reference in New Issue
Block a user