only sleep on backfill nulls if updates are made

Change-Id: Ia7183a8de2aae2c8e3992d1378efc2861b41ea9d
Reviewed-on: https://gerrit.instructure.com/202452
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
James Williams 2019-07-24 09:34:38 -06:00
parent 920391503f
commit 2ca5530ff7
1 changed files with 2 additions and 2 deletions

View File

@ -49,9 +49,9 @@ module DataFixup
end
klass.find_ids_in_ranges(batch_size: batch_size) do |start_id, end_id|
scope.where(id: start_id..end_id).update_all(updates)
update_count = scope.where(id: start_id..end_id).update_all(updates)
sleep_interval_per_batch = Setting.get("sleep_interval_per_backfill_nulls_batch", nil).presence&.to_f
sleep(sleep_interval_per_batch) if sleep_interval_per_batch
sleep(sleep_interval_per_batch) if update_count > 0 && sleep_interval_per_batch
end
end
end