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:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-10-15 00:32:44 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-10-19 19:58:27 +0300
commit67314e95ae836365fa1989439a6379aac781a0b4 (patch)
tree7f364243353cbc8ac311fc54119ad64ec41452b0 /app/models/label.rb
parent297892011330ecdd2fa7cbe47fbc6fd4f3b62171 (diff)
Add support to group labels prioritization on project level
Diffstat (limited to 'app/models/label.rb')
-rw-r--r--app/models/label.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/models/label.rb b/app/models/label.rb
index 3ce4e253035..ea11d9d7864 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -32,12 +32,14 @@ class Label < ActiveRecord::Base
scope :templates, -> { where(template: true) }
scope :with_title, ->(title) { where(title: title) }
- def self.prioritized
- where.not(priority: nil).reorder(:priority, :title)
+ def self.prioritized(project)
+ joins(:priorities)
+ .where(label_priorities: { project_id: project })
+ .reorder('label_priorities.priority ASC, labels.title ASC')
end
- def self.unprioritized
- where(priority: nil)
+ def self.unprioritized(project)
+ where.not(id: prioritized(project).select(:id))
end
alias_attribute :name, :title