Skip to content
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

remove query.Sorting from registration.go #19962

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/pkg/scan/dao/scanner/registration.go
Expand Up @@ -123,8 +123,14 @@ 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 {
for _, sort := range query.Sorts {
sortKey := sort.Key
if sort.DESC {
sortKey += " DESC"
}
qs = qs.OrderBy(sortKey)
Copy link
Contributor

@stonezdj stonezdj Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supposing there are two columns in the query.Sorts, the query will always sort with the last column.
Prefer to use this style:

qs = qs.OrderBy("-is_default", "-create_time")

}
} else {
qs = qs.OrderBy("-is_default", "-create_time")
}
Expand Down