summaryrefslogtreecommitdiff
path: root/app/models/issue.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-04-19 13:10:25 +0200
committerRobert Speicher <rspeicher@gmail.com>2016-04-20 15:43:32 -0400
commit159f959b6106a750d0ab89dce95a954ee33ffa84 (patch)
tree02594451a542a06e0fe6a3e594a74644fe784fc1 /app/models/issue.rb
parent6cdf4acd4eef55c616d633757772c6e05f6b93c5 (diff)
downloadgitlab-ce-159f959b6106a750d0ab89dce95a954ee33ffa84.tar.gz
Move due_date sort scopes to Issue and fix CHANGELOG
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r--app/models/issue.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index d72233006ee..9a382fcda8d 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -46,6 +46,9 @@ class Issue < ActiveRecord::Base
scope :open_for, ->(user) { opened.assigned_to(user) }
scope :in_projects, ->(project_ids) { where(project_id: project_ids) }
+ 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') }
+
state_machine :state, initial: :opened do
event :close do
transition [:reopened, :opened] => :closed
@@ -89,6 +92,15 @@ class Issue < ActiveRecord::Base
@link_reference_pattern ||= super("issues", /(?<issue>\d+)/)
end
+ def self.sort(method)
+ case method.to_s
+ when 'due_date_asc' then order_due_date_asc
+ when 'due_date_desc' then order_due_date_desc
+ else
+ super
+ end
+ end
+
def to_reference(from_project = nil)
reference = "#{self.class.reference_prefix}#{iid}"