diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-09-20 18:00:18 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-19 19:58:24 +0300 |
commit | 1c73d302e2ce5a27aba7171af741b3590d48aba9 (patch) | |
tree | 345307683181702a387a2f2f1ea2c237905bdb75 /app/controllers/projects/labels_controller.rb | |
parent | b10e5764ac0765b556d64dfebb9dad948154e31a (diff) |
Avoid an extra a query per label when setting label priority
Diffstat (limited to 'app/controllers/projects/labels_controller.rb')
-rw-r--r-- | app/controllers/projects/labels_controller.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 33c3b7f79c2..919c6f239cb 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -97,8 +97,9 @@ class Projects::LabelsController < Projects::ApplicationController def set_priorities Label.transaction do params[:label_ids].each_with_index do |label_id, index| - label = labels.find_by_id(label_id) - label.update_attribute(:priority, index) if label + next unless labels.where(id: label_id).any? + + Label.where(id: label_id).update_all(priority: index) end end |