Avoid an extra a query per label when setting label priority

parent b10e5764
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment