Skip to content

Commit 9b7af43

Browse files
authored
Perform Newest sort type correctly when sorting issues (#30644)
Should resolve #30642. Before this commit, we were treating an empty `?sort=` query parameter as the correct sorting type (which is to sort issues in descending order by their created UNIX time). But when we perform `sort=latest`, we did not include this as a type so we would sort by the most recently updated when reaching the `default` switch statement block. This commit fixes this by considering the empty string, "latest", and just any other string that is not mentioned in the switch statement as sorting by newest.
1 parent 370b1bd commit 9b7af43

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/indexer/issues/dboptions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOp
6868
searchOpt.Paginator = opts.Paginator
6969

7070
switch opts.SortType {
71-
case "":
71+
case "", "latest":
7272
searchOpt.SortBy = SortByCreatedDesc
7373
case "oldest":
7474
searchOpt.SortBy = SortByCreatedAsc
@@ -86,7 +86,7 @@ func ToSearchOptions(keyword string, opts *issues_model.IssuesOptions) *SearchOp
8686
searchOpt.SortBy = SortByDeadlineDesc
8787
case "priority", "priorityrepo", "project-column-sorting":
8888
// Unsupported sort type for search
89-
searchOpt.SortBy = SortByUpdatedDesc
89+
fallthrough
9090
default:
9191
searchOpt.SortBy = SortByUpdatedDesc
9292
}

0 commit comments

Comments
 (0)