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

26 lines
722 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2020-04-08 14:13:33 +05:30
class RemoteMirrorNotificationWorker # rubocop:disable Scalability/IdempotentWorker
2019-02-15 15:39:39 +05:30
include ApplicationWorker
2021-10-27 15:23:28 +05:30
data_consistency :always
2021-06-08 01:23:25 +05:30
sidekiq_options retry: 3
2019-12-21 20:55:43 +05:30
feature_category :source_code_management
2020-03-13 15:44:24 +05:30
weight 2
2019-12-21 20:55:43 +05:30
2019-02-15 15:39:39 +05:30
def perform(remote_mirror_id)
2019-10-12 21:52:04 +05:30
remote_mirror = RemoteMirror.find_by_id(remote_mirror_id)
2019-02-15 15:39:39 +05:30
# We check again if there's an error because a newer run since this job was
# fired could've completed successfully.
return unless remote_mirror && remote_mirror.last_error.present?
return if remote_mirror.error_notification_sent?
NotificationService.new.remote_mirror_update_failed(remote_mirror)
remote_mirror.after_sent_notification
end
end