Skip to content

Adjust milestone sort order for due date. Non due date milestone will be considered after all due date milestone #35200

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

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions models/issues/milestone_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (opts FindMilestoneOptions) ToConds() builder.Cond {
func (opts FindMilestoneOptions) ToOrders() string {
switch opts.SortType {
case "furthestduedate":
return "deadline_unix DESC"
return "CASE WHEN deadline_unix = 0 OR deadline_unix IS NULL THEN 0 ELSE 1 END, deadline_unix DESC, name ASC"
case "leastcomplete":
return "completeness ASC"
case "mostcomplete":
Expand All @@ -73,7 +73,7 @@ func (opts FindMilestoneOptions) ToOrders() string {
case "name":
return "name DESC"
default:
return "deadline_unix ASC, name ASC"
return "CASE WHEN deadline_unix = 0 OR deadline_unix IS NULL THEN 1 ELSE 0 END, deadline_unix ASC, name ASC"
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/api_issue_milestone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestAPIIssuesMilestone(t *testing.T) {
resp = MakeRequest(t, req, http.StatusOK)
DecodeJSON(t, resp, &apiMilestones)
assert.Len(t, apiMilestones, 4)
assert.Nil(t, apiMilestones[0].Deadline)
assert.Nil(t, apiMilestones[3].Deadline)

req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/milestones/%s", owner.Name, repo.Name, apiMilestones[2].Title)).
AddTokenAuth(token)
Expand Down