Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors shop-page caching so the controller reads a single cached payload per request and derives “recently added” items from the already-cached buyable items, reducing redundant cache fetches and avoiding an extra query.
Changes:
- Replace
cached_buyable_standalonewithcached_shop_page_datathat returns bothbuyable_standaloneandrecently_added. - Compute
recently_addedin-memory from the cachedbuyable_standalonelist to reduce cache/query duplication. - Rename cache invalidation to
invalidate_shop_page_cache/invalidate_shop_page_cache!and simplify ActiveStorage includes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/models/shop_item.rb | Introduces a unified shop-page cache payload and renames the cache key + invalidation methods. |
| app/controllers/shop_controller.rb | Updates shop item loading to use the unified cached payload (single fetch) and uses cached “recently added”. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
57af1cf to
ad8b69a
Compare
3kh0
approved these changes
Mar 11, 2026
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.
Changes
cached_shop_page_dataonce and destructures bothbuyable_standaloneandrecently_addedfrom the result, eliminating a redundant double-fetch of the same cache blob per request.recently_addedis now filtered in-memory from thebuyable_standalonearray instead of running a separate DB query, reducing cache payload size.:recordfromincludes(image_attachment: [:blob, :record])since it refers back to the already-loadedShopItem.invalidate_buyable_standalone_cache→invalidate_shop_page_cacheto accurately reflect the broader scope of the cache key.