Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 12:55:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 12:55:51 +0300
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /app/finders/milestones_finder.rb
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'app/finders/milestones_finder.rb')
-rw-r--r--app/finders/milestones_finder.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/app/finders/milestones_finder.rb b/app/finders/milestones_finder.rb
index 5d2a54ac979..5fe55e88086 100644
--- a/app/finders/milestones_finder.rb
+++ b/app/finders/milestones_finder.rb
@@ -18,6 +18,8 @@ class MilestonesFinder
attr_reader :params
+ EXPIRED_LAST_SORTS = %i[expired_last_due_date_asc expired_last_due_date_desc].freeze
+
def initialize(params = {})
@params = params
end
@@ -70,7 +72,16 @@ class MilestonesFinder
end
def order(items)
- sort_by = params[:sort].presence || 'due_date_asc'
- items.sort_by_attribute(sort_by)
+ sort_by = params[:sort].presence || :due_date_asc
+
+ if sort_by_expired_last?(sort_by)
+ items.sort_with_expired_last(sort_by)
+ else
+ items.sort_by_attribute(sort_by)
+ end
+ end
+
+ def sort_by_expired_last?(sort_by)
+ EXPIRED_LAST_SORTS.include?(sort_by)
end
end