# This rearranges the fields order in the forms fields table to be in an actual real order.

class Maintenance::Forms::FieldsOrderJob
  include Sidekiq::Worker

  def perform(school_id)
    school = School.find(school_id)
    school.forms.each do |form|
      form.fields.order(:position).each_with_index do |field, index|
        field.update(position: index + 1)
      end
    end
  end
end
