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:
authorAlejandro Rodríguez <alejorro70@gmail.com>2016-10-28 03:26:56 +0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2016-10-28 03:26:56 +0300
commit7bd6ff03d8cc08673497e3b574efce1648f27da0 (patch)
treebb7022f70629314644270849c5c40da01ecf3f8e /app/models/concerns/sortable.rb
parent20a7db4483904c7280093a0309a63dfd1b7ef72e (diff)
Fix and improve `Sortable.highest_label_priority`
Diffstat (limited to 'app/models/concerns/sortable.rb')
-rw-r--r--app/models/concerns/sortable.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/app/models/concerns/sortable.rb b/app/models/concerns/sortable.rb
index 12b23f00769..7edb0acd56c 100644
--- a/app/models/concerns/sortable.rb
+++ b/app/models/concerns/sortable.rb
@@ -38,16 +38,21 @@ module Sortable
private
- def highest_label_priority(target_type:, target_column:, project_column:, excluded_labels: [])
+ def highest_label_priority(target_type_column: nil, target_type: nil, target_column:, project_column:, excluded_labels: [])
query = Label.select(LabelPriority.arel_table[:priority].minimum).
left_join_priorities.
joins(:label_links).
where("label_priorities.project_id = #{project_column}").
- where(label_links: { target_type: target_type }).
where("label_links.target_id = #{target_column}").
reorder(nil)
- query.where.not(title: excluded_labels) if excluded_labels.present?
+ if target_type_column
+ query = query.where("label_links.target_type = #{target_type_column}")
+ else
+ query = query.where(label_links: { target_type: target_type })
+ end
+
+ query = query.where.not(title: excluded_labels) if excluded_labels.present?
query
end