summaryrefslogtreecommitdiff
path: root/app/models/issue.rb
diff options
context:
space:
mode:
authorSimon Knox <psimyn@gmail.com>2019-06-05 06:11:56 +1000
committerSimon Knox <psimyn@gmail.com>2019-06-05 06:11:56 +1000
commit443f87a7ed996017bc577f14fda586792e2216cf (patch)
tree5c2ce3dfb1f0dfa7c8552462e0a2dfb23adcd31a /app/models/issue.rb
parent6f4ed5149d32e1b199a594db08a69366b2a85217 (diff)
parent632427bcc24403be21df5afe8e6bae9cf41c8bc7 (diff)
downloadgitlab-ce-58516-dashboard-endpoint-fe.tar.gz
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce into 58516-dashboard-endpoint-fe58516-dashboard-endpoint-fe
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index eb5544f2a12..6da6fbe55cb 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -58,6 +58,7 @@ class Issue < ApplicationRecord
scope :order_due_date_asc, -> { reorder('issues.due_date IS NULL, issues.due_date ASC') }
scope :order_due_date_desc, -> { reorder('issues.due_date IS NULL, issues.due_date DESC') }
scope :order_closest_future_date, -> { reorder('CASE WHEN issues.due_date >= CURRENT_DATE THEN 0 ELSE 1 END ASC, ABS(CURRENT_DATE - issues.due_date) ASC') }
+ scope :order_relative_position_asc, -> { reorder(::Gitlab::Database.nulls_last_order('relative_position', 'ASC')) }
scope :preload_associations, -> { preload(:labels, project: :namespace) }
scope :with_api_entity_associations, -> { preload(:timelogs, :assignees, :author, :notes, :labels, project: [:route, { namespace: :route }] ) }
@@ -130,9 +131,10 @@ class Issue < ApplicationRecord
def self.sort_by_attribute(method, excluded_labels: [])
case method.to_s
when 'closest_future_date' then order_closest_future_date
- when 'due_date' then order_due_date_asc
- when 'due_date_asc' then order_due_date_asc
- when 'due_date_desc' then order_due_date_desc
+ when 'due_date' then order_due_date_asc
+ when 'due_date_asc' then order_due_date_asc
+ when 'due_date_desc' then order_due_date_desc
+ when 'relative_position' then order_relative_position_asc
else
super
end