diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /app/models/milestone.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'app/models/milestone.rb')
-rw-r--r-- | app/models/milestone.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 9ed6c106e45..2168d57693e 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -120,6 +120,19 @@ class Milestone < ApplicationRecord sorted.with_order_id_desc end + def self.sort_with_expired_last(method) + # NOTE: this is a custom ordering of milestones + # to prioritize displaying non-expired milestones and milestones without due dates + sorted = reorder(Arel.sql("(CASE WHEN due_date IS NULL THEN 1 WHEN due_date >= CURRENT_DATE THEN 0 ELSE 2 END) ASC")) + sorted = if method.to_s == 'expired_last_due_date_desc' + sorted.order(due_date: :desc) + else + sorted.order(due_date: :asc) + end + + sorted.with_order_id_desc + end + def self.states_count(projects, groups = nil) return STATE_COUNT_HASH unless projects || groups |