diff options
author | Phil Hughes <me@iamphill.com> | 2016-08-30 13:49:31 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-08-30 13:49:31 +0100 |
commit | 172aab108b875e8dc9a5f1d3c2d53018eff76ea1 (patch) | |
tree | 068fa858eeaa8faa7c65f189d8189e33a83c86a3 /app/models/concerns/sortable.rb | |
parent | 45fa7fd4ddf35314602168cd869ee4a67c44250b (diff) | |
parent | 2778dec131c2afac9fcdb2c42365b69099a5ae5b (diff) | |
download | gitlab-ce-172aab108b875e8dc9a5f1d3c2d53018eff76ea1.tar.gz |
Merge branch 'master' into autocomplete-space-prefix
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 |