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