diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2016-06-02 14:57:31 -0500 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2016-06-06 11:59:49 -0500 |
commit | 8f0bf297676dac33ecc8ced10da5ae88f36a9ab0 (patch) | |
tree | e619a36d311601be1dafbe19c30feeb5212cea96 /app/models | |
parent | bf0c4426ffb1994b647a4f7e8c74b0fef29645d2 (diff) | |
download | gitlab-ce-8f0bf297676dac33ecc8ced10da5ae88f36a9ab0.tar.gz |
Add unprioritized scope
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/label.rb | 8 |
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 |