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-02 15:08:31 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-02 15:08:31 +0300
commitafbfbfc87abfa006f1d369fdf9c740eb1c826808 (patch)
tree39f6be835193c63660961d536a185711625fe160 /app/finders
parent26eb09cbe9c3cc9fc78ad1be7e66e85b5645844b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-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