diff options
author | koalp <49921473+koalp@users.noreply.github.com> | 2021-06-15 03:15:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-14 21:15:56 -0400 |
commit | 864f0c044704a0151948b09be5d1f3c448df8584 (patch) | |
tree | ace10d570eb28dfde8af8f5d9affc96c0a1bd036 /models/issue.go | |
parent | 95352e6bd55428bed947dbe2e6427ee93240bbe8 (diff) | |
download | gitea-864f0c044704a0151948b09be5d1f3c448df8584.tar.gz gitea-864f0c044704a0151948b09be5d1f3c448df8584.zip |
Use milestone deadline when sorting issues (#14551)
When sorting issues by deadline, the deadline of the milestone the issue
is attached to wasn't taken into account.
It have been changed and the nearest deadline is taken into account for
sorting.
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'models/issue.go')
-rw-r--r-- | models/issue.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/models/issue.go b/models/issue.go index 769988795a..f1a092debd 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1127,9 +1127,18 @@ func sortIssuesSession(sess *xorm.Session, sortType string, priorityRepoID int64 sess.Desc("issue.priority") case "nearduedate": // 253370764800 is 01/01/9999 @ 12:00am (UTC) - sess.OrderBy("CASE WHEN issue.deadline_unix = 0 THEN 253370764800 ELSE issue.deadline_unix END ASC") + sess.Join("LEFT", "milestone", "issue.milestone_id = milestone.id"). + OrderBy("CASE " + + "WHEN issue.deadline_unix = 0 AND (milestone.deadline_unix = 0 OR milestone.deadline_unix IS NULL) THEN 253370764800 " + + "WHEN milestone.deadline_unix = 0 OR milestone.deadline_unix IS NULL THEN issue.deadline_unix " + + "WHEN milestone.deadline_unix < issue.deadline_unix OR issue.deadline_unix = 0 THEN milestone.deadline_unix " + + "ELSE issue.deadline_unix END ASC") case "farduedate": - sess.Desc("issue.deadline_unix") + sess.Join("LEFT", "milestone", "issue.milestone_id = milestone.id"). + OrderBy("CASE " + + "WHEN milestone.deadline_unix IS NULL THEN issue.deadline_unix " + + "WHEN milestone.deadline_unix < issue.deadline_unix OR issue.deadline_unix = 0 THEN milestone.deadline_unix " + + "ELSE issue.deadline_unix END DESC") case "priorityrepo": sess.OrderBy("CASE WHEN issue.repo_id = " + strconv.FormatInt(priorityRepoID, 10) + " THEN 1 ELSE 2 END, issue.created_unix DESC") default: |