-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
replaced query.Sorting with query.Sorts #20723
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #20723 +/- ##
===========================================
+ Coverage 45.36% 66.23% +20.86%
===========================================
Files 244 1045 +801
Lines 13333 113508 +100175
Branches 2719 2845 +126
===========================================
+ Hits 6049 75178 +69129
- Misses 6983 34222 +27239
- Partials 301 4108 +3807
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -123,10 +123,18 @@ func ListRegistrations(ctx context.Context, query *q.Query) ([]*Registration, er | |||
} | |||
|
|||
// Order the list | |||
if query.Sorting != "" { | |||
qs = qs.OrderBy(query.Sorting) | |||
if len(query.Sorts) > 0 { |
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 think the following logic is duplicated because when call the orm.QuerySetter
, there will be a common setSorts
function to handle it.
Line 210 in 0da13eb
func setSorts(qs orm.QuerySeter, query *q.Query, meta *metadata) orm.QuerySeter { |
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, the Query Setter
is already returning in sorted order and we just have to remove the explicit Sorting from the code?
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.
Yes, since there is a common logic processing, there is no need for redundant processing here.
Signed-off-by: Its-Maniaco <21123621+Its-Maniaco@users.noreply.github.com>
Signed-off-by: Its-Maniaco <21123621+Its-Maniaco@users.noreply.github.com>
484af6f
to
62e31ad
Compare
if query.Sorting != "" { | ||
qs = qs.OrderBy(query.Sorting) | ||
} else { | ||
qs = qs.OrderBy("-is_default", "-create_time") |
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.
Please check if we need to keep this line to ensure backward compatibility without introducing inconsistent results from previous versions, because the common query logic processor will not handle this special case.
This PR is being marked stale due to a period of inactivty. If this PR is still relevant, please comment or remove the stale label. Otherwise, this PR will close in 30 days. |
Fixes #19569
Replaced deprecated
query.Sorting
withquery.Sorts
insrc/pkg/scan/dao/scanner/registration.go