Merged
Conversation
We introduced a custom Ransacker to allow filtering producs by their variants option values in the new admin interface. This ransacker is broken in latest Ransack v4.2 and overly complicated. By introducing a option_values association to products, that does the same join over variants_including_master and their distinct option_values we can use normal ransack search. Quoting the Ransack documentation: > "Ransackers, like scopes, are not a cure-all. Many use cases can be better solved with a standard Ransack search on a dedicated database search field, which is faster, index-able, and scales better than converting/ransacking data on the fly."
Now that we removed the broken ransacker in previous commit, we can allow Ransack v4.2 - with Rails 7.2 support - again.
Member
Author
|
Thinking about back porting this to 4.3 and 4.2 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5853 +/- ##
==========================================
- Coverage 89.24% 89.23% -0.01%
==========================================
Files 753 752 -1
Lines 17519 17508 -11
==========================================
- Hits 15635 15624 -11
Misses 1884 1884 ☔ View full report in Codecov by Sentry. |
fa6d589 to
d8c3bf2
Compare
We do not use the custom ransacker this was necessary for
d8c3bf2 to
ae69534
Compare
adammathys
approved these changes
Sep 12, 2024
MadelineCollier
approved these changes
Sep 13, 2024
Contributor
MadelineCollier
left a comment
There was a problem hiding this comment.
Nice work, thanks! 🎉
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
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.
Summary
In #5395 we introduced a custom Ransacker to allow filtering products by their variants option values in the new admin interface.
This ransacker is broken in latest Ransack v4.2 and overly complicated. By introducing a
option_valuesassociation to products, that does the same join overvariants_including_masterand their distinctoption_valueswe can use a normal Ransack search instead.Quoting the Ransack documentation:
This also makes it possible to address N+1 query that can get very nasty with a list of many products with lots of variants.
Checklist
Check out our PR guidelines for more details.
The following are mandatory for all PRs:
The following are not always needed: