gitlab-org--gitlab-foss/app/workers/admin_email_worker.rb

30 lines
847 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class AdminEmailWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
data_consistency :always
# 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
feature_category :source_code_management
2016-04-04 11:23:43 -04:00
def perform
send_repository_check_mail if Gitlab::CurrentSettings.repository_checks_enabled
end
private
# rubocop: disable CodeReuse/ActiveRecord
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
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
# rubocop: enable CodeReuse/ActiveRecord
2016-04-04 11:23:43 -04:00
end