2018-06-27 07:23:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 18:09:10 +00:00
|
|
|
class AdminEmailWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2020-02-10 12:08:59 +00:00
|
|
|
# rubocop:disable Scalability/CronWorkerContext
|
|
|
|
# This worker does not perform work scoped to a context
|
|
|
|
include CronjobQueue
|
|
|
|
# rubocop:enable Scalability/CronWorkerContext
|
2016-04-04 15:23:43 +00:00
|
|
|
|
2020-02-18 18:09:07 +00:00
|
|
|
feature_category :source_code_management
|
2019-10-18 11:11:44 +00:00
|
|
|
|
2016-04-04 15:23:43 +00:00
|
|
|
def perform
|
2018-04-19 14:03:56 +00:00
|
|
|
send_repository_check_mail if Gitlab::CurrentSettings.repository_checks_enabled
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2018-04-19 14:03:56 +00:00
|
|
|
def send_repository_check_mail
|
2016-04-06 11:47:05 +00:00
|
|
|
repository_check_failed_count = Project.where(last_repository_check_failed: true).count
|
2020-08-12 06:09:53 +00:00
|
|
|
return if repository_check_failed_count == 0
|
2016-04-04 15:23:43 +00:00
|
|
|
|
2016-04-06 11:47:05 +00:00
|
|
|
RepositoryCheckMailer.notify(repository_check_failed_count).deliver_now
|
2016-04-04 15:23:43 +00:00
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-04-04 15:23:43 +00:00
|
|
|
end
|