Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
AO3-1234 Fix thing)Issue
https://otwarchive.atlassian.net/browse/AO3-7627
Purpose
Every series blurb on the index ran ~7 queries (tags, byline pseuds/users, counts, dates, bookmarks), and unlike work blurbs there is no fragment cache, so a page of 20 series ran ~140 queries on every render.
This PR:
for_blurbtopreload({ pseuds: :user }, works: :tags)and chains it inSeriesController#index.preloadinstead ofincludesbecause the index relation carries the string join withGROUP BYfromexclude_anonymous, andincludescould switch to a single-query eager load and break the paginated query.tag_groups,visible_work_count,revised_at, word counts) filter the preloaded works in Ruby when the association is loaded, mirroring the original SQL exactly; otherwise the original SQL runs unchanged, so#showkeeps its current behavior.revised_atuses a Ruby mirror ofWork.visible_to_user.tag_groups(called three times per blurb) and switches the view to the existing cachedpublic_bookmark_count, the one remaining per-series query.Note on pre-existing behavior:
visible_work_countfor guests counts works hidden by an admin, same as the original SQL. This PR aims for parity, not behavior changes, so it keeps that as is.Testing Instructions
Series listings (a user's series page, a fandom's series listing) should show the same blurbs as before:
The bookmark count in the blurb is now cached for up to 2 hours (like work and bookmark blurbs already do)
References
Same kind of fix as AO3-7356.
for_blurbis also applied to series in bookmark search results, which get the same benefit.Credit
Pablo Monfort (he/him)