debian-mirror-gitlab/app/workers/admin_email_worker.rb

30 lines
847 B
Ruby
Raw Normal View History

2018-11-08 19:23:39 +05:30
# frozen_string_literal: true
2020-04-08 14:13:33 +05:30
class AdminEmailWorker # rubocop:disable Scalability/IdempotentWorker
2018-03-17 18:26:18 +05:30
include ApplicationWorker
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
data_consistency :always
2020-03-13 15:44:24 +05:30
# rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
2016-11-03 12:29:30 +05:30
include CronjobQueue
2020-03-13 15:44:24 +05:30
# rubocop:enable Scalability/CronWorkerContext
2016-06-02 11:05:42 +05:30
2020-04-08 14:13:33 +05:30
feature_category :source_code_management
2019-12-21 20:55:43 +05:30
2016-06-02 11:05:42 +05:30
def perform
2018-10-15 14:42:47 +05:30
send_repository_check_mail if Gitlab::CurrentSettings.repository_checks_enabled
end
private
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2018-10-15 14:42:47 +05:30
def send_repository_check_mail
2016-06-02 11:05:42 +05:30
repository_check_failed_count = Project.where(last_repository_check_failed: true).count
2020-10-24 23:57:45 +05:30
return if repository_check_failed_count == 0
2016-06-02 11:05:42 +05:30
RepositoryCheckMailer.notify(repository_check_failed_count).deliver_now
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2016-06-02 11:05:42 +05:30
end