diff options
author | Felipe Artur <felipefac@gmail.com> | 2016-07-26 18:21:20 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2016-08-19 16:14:20 -0300 |
commit | 37bf35f0bcba28e271789542fb8c81a6c77236b6 (patch) | |
tree | aa10aa7fbff70b17f9978cbe4aced667197062d9 /app/models/concerns/sortable.rb | |
parent | 415159c28da1aec00bb383d46aad67a9de75faae (diff) | |
download | gitlab-ce-37bf35f0bcba28e271789542fb8c81a6c77236b6.tar.gz |
Todos sorting dropdownissue_18135
Diffstat (limited to 'app/models/concerns/sortable.rb')
-rw-r--r-- | app/models/concerns/sortable.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/concerns/sortable.rb b/app/models/concerns/sortable.rb index 8b47b9e0abd..1ebecd86af9 100644 --- a/app/models/concerns/sortable.rb +++ b/app/models/concerns/sortable.rb @@ -35,5 +35,19 @@ module Sortable all end end + + private + + def highest_label_priority(object_types, condition_field, excluded_labels: []) + query = Label.select(Label.arel_table[:priority].minimum). + joins(:label_links). + where(label_links: { target_type: object_types }). + where("label_links.target_id = #{condition_field}"). + reorder(nil) + + query.where.not(title: excluded_labels) if excluded_labels.present? + + query + end end end |