diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-15 02:06:26 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-19 19:58:27 +0300 |
commit | 3c2aaec1f2624ad4817e7ac52120985682afa448 (patch) | |
tree | 45832f21636e5a33557f715a5d95c36c6be290a9 /app/models/concerns/sortable.rb | |
parent | 99e928f103182b58156edb107b55344eaafc6772 (diff) |
Fix sorting by label priorities
Diffstat (limited to 'app/models/concerns/sortable.rb')
-rw-r--r-- | app/models/concerns/sortable.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/app/models/concerns/sortable.rb b/app/models/concerns/sortable.rb index 1ebecd86af9..83e551fd152 100644 --- a/app/models/concerns/sortable.rb +++ b/app/models/concerns/sortable.rb @@ -38,10 +38,12 @@ module Sortable private - def highest_label_priority(object_types, condition_field, excluded_labels: []) - query = Label.select(Label.arel_table[:priority].minimum). + def highest_label_priority(object_types, project_field, condition_field, excluded_labels: []) + query = Label.select(LabelPriority.arel_table[:priority].minimum). + left_join_priorities. joins(:label_links). where(label_links: { target_type: object_types }). + where("label_priorities.project_id = #{project_field}"). where("label_links.target_id = #{condition_field}"). reorder(nil) |