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:
Bianca Nenciu
2024-09-18 12:01:40 +03:00
committed by GitHub
parent 02380af75c
commit dd5502f166
4 changed files with 70 additions and 131 deletions

View File

@ -45,13 +45,9 @@ RSpec.describe PostsController do
# Expected queries:
#
# - all queries listed for "when not logged in"
# - all queries listed for "when not logged in" (except it loads voters for polls in post5, post6 and post7)
# - query to find out if the user has voted in each poll
# - queries to get "serialized voters" (NOT TRACKED)
# - voters for poll in post5
# - voters for poll in post6
# - voters for poll in post7
expect(poll_queries.size).to eq(8)
expect(poll_queries.size).to eq(6)
end
end
end