Compare commits

...

5 Commits

2 changed files with 3 additions and 3 deletions

View File

@ -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":
@ -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"
}
}

View File

@ -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)