-
Notifications
You must be signed in to change notification settings - Fork 0
Allow dynamic sorting #31
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
Conversation
When sorting certain types of attributes, e.g. JSONB values, it is not possible to know ahead of time what attributes to explicitly expose. Introduce prefix-based dynamic sorting so arbitrary sort attributes can be passed to the sort class/proc.
4a32b6d to
36e98fc
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.
Pull Request Overview
This PR introduces dynamic sorting functionality that allows prefix-based sorting for scenarios where the exact sort attributes cannot be determined ahead of time, such as JSONB values or dynamic data structures.
- Adds
dynamically_sorts_bymethod to register prefix-based dynamic sort handlers - Refactors existing sort system to use
StaticandDynamicsort classes for unified handling - Introduces
DynamicSortbase class for implementing custom dynamic sort behavior
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/jsonapi/query_builder/mixins/sort.rb | Core implementation of dynamic sorting logic and refactored static sort handling |
| lib/jsonapi/query_builder/mixins/sort/static.rb | New Static sort class for handling traditional fixed-attribute sorting |
| lib/jsonapi/query_builder/mixins/sort/dynamic.rb | New Dynamic sort class for handling prefix-based dynamic sorting |
| lib/jsonapi/query_builder/dynamic_sort.rb | Base class for implementing custom dynamic sort behavior |
| lib/jsonapi/query_builder.rb | Added require for the new DynamicSort class |
| spec/jsonapi/query_builder/mixins/sort_spec.rb | Updated tests to reflect new sort structure and added dynamic sort test coverage |
| spec/jsonapi/query_builder/mixins/sort/static_spec.rb | Test coverage for the new Static sort class |
| spec/jsonapi/query_builder/mixins/sort/dynamic_spec.rb | Test coverage for the new Dynamic sort class |
| spec/jsonapi/query_builder/dynamic_sort_spec.rb | Test coverage for the DynamicSort base class |
| README.md | Documentation explaining dynamic sorting usage with examples |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1173
When sorting certain types of attributes, e.g. JSONB values, it is not possible to know ahead of time what attributes to explicitly expose. Introduce prefix-based dynamic sorting so arbitrary sort attributes can be passed to the sort class/proc.