2018-06-27 07:31:41 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-13 13:56:05 +00:00
|
|
|
module RepositoryCheck
|
2020-02-19 18:09:10 +00:00
|
|
|
class ClearWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2021-04-30 18:10:09 +00:00
|
|
|
|
2021-07-21 12:09:35 +00:00
|
|
|
data_consistency :always
|
|
|
|
|
2021-04-30 18:10:09 +00:00
|
|
|
sidekiq_options retry: 3
|
2016-10-21 16:13:41 +00:00
|
|
|
include RepositoryCheckQueue
|
2016-04-14 16:28:48 +00:00
|
|
|
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-04-13 13:56:05 +00:00
|
|
|
def perform
|
2016-04-13 15:33:25 +00:00
|
|
|
# Do small batched updates because these updates will be slow and locking
|
|
|
|
Project.select(:id).find_in_batches(batch_size: 100) do |batch|
|
2016-04-13 13:56:05 +00:00
|
|
|
Project.where(id: batch.map(&:id)).update_all(
|
|
|
|
last_repository_check_failed: nil,
|
2017-05-03 11:27:17 +00:00
|
|
|
last_repository_check_at: nil
|
2016-04-13 13:56:05 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-04-13 13:56:05 +00:00
|
|
|
end
|
2016-04-14 16:28:48 +00:00
|
|
|
end
|