-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Ransack 4.2 support #5853
Add Ransack 4.2 support #5853
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.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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_values
association to products, that does the same join overvariants_including_master
and their distinctoption_values
we 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: