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
Fixes #35795,35213 - fix Repo Sets pagination, sorting, filtering #10373
Merged
jeremylenz
merged 1 commit into
Katello:master
from
jeremylenz:35795-repo-sets-sorting-filtering
Dec 6, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
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.
This only worked once I realized that I needed to call
reorder
instead oforder
, since that eliminates a defaultORDER BY
that was causing the custom sort to be ignored.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.
I'm a bit confused about how this is working.
array_position
is supposed to return a single position of an element found in an array. But here, instead of an element, a table's ID field is being passed in as the second argument.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.
{#{sort_order.join(',')}}'::int[]
<-- So this creates a sorted array of product_content IDs, sorted in the way we want them sorted. The second argument is saying, "find where this ID is in that array, and then sort by that."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.
It seems a little weird to me that the controller is turning a relation into an array (i.e. executing a postgres transaction) and then turning it back into a relation.
Instead, would it be possible to ensure that
relation
is actually a relation when it's sent toscoped_search
? Then, the ordering can be applied as usual. It's a little odd thatrelation
isn't actually a relation by the time it is passed intoscoped_search
anyway (right?).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.
So for example, it'll make an array of IDs like
and then the SQL will be like
which evaluates to something like
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.
relation
is always a relation. I made sure of this, since that's whatscoped_search
needs. Here's the journey it goes through:index_relation
is a relation at the end of the method. It may or may not continue ontoindex_relation_with_consumable_overrides
. If it does,index_relation_with_consumable_overrides
, it makesProductContentFinder
s to adorn the items with the necessary override data, and do the necessary filtering. It then converts it back to a relation before exiting the method.scoped_search
as a relation, as required.The reason all this is necessary is because
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.
I'm convinced! Thanks for the details.