summaryrefslogtreecommitdiff
path: root/app/models/label.rb
diff options
context:
space:
mode:
authorAlfredo Sumaran <alfredo@gitlab.com>2016-06-02 14:57:31 -0500
committerAlfredo Sumaran <alfredo@gitlab.com>2016-06-06 11:59:49 -0500
commit8f0bf297676dac33ecc8ced10da5ae88f36a9ab0 (patch)
treee619a36d311601be1dafbe19c30feeb5212cea96 /app/models/label.rb
parentbf0c4426ffb1994b647a4f7e8c74b0fef29645d2 (diff)
downloadgitlab-ce-8f0bf297676dac33ecc8ced10da5ae88f36a9ab0.tar.gz
Add unprioritized scope
Diffstat (limited to 'app/models/label.rb')
-rw-r--r--app/models/label.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/label.rb b/app/models/label.rb
index 7fd77880558..9e04c5263bd 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -32,10 +32,12 @@ class Label < ActiveRecord::Base
scope :templates, -> { where(template: true) }
- def self.prioritized(bool = true)
- query = bool ? where.not(priority: nil) : where(priority: nil)
+ def self.prioritized
+ where.not(priority: nil).reorder(Gitlab::Database.nulls_last_order(:priority), :title)
+ end
- query.reorder(Gitlab::Database.nulls_last_order(:priority), :title)
+ def self.unprioritized
+ where(priority: nil).reorder(Gitlab::Database.nulls_last_order(:priority), :title)
end
alias_attribute :name, :title