Class: SshKeys::ExpiringSoonNotificationWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, CronjobQueue
Defined in:
app/workers/ssh_keys/expiring_soon_notification_worker.rb

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#performObject


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/workers/ssh_keys/expiring_soon_notification_worker.rb', line 14

def perform
  # rubocop:disable CodeReuse/ActiveRecord
  User.with_ssh_key_expiring_soon.find_each(batch_size: 10_000) do |user|
    with_context(user: user) do
      Gitlab::AppLogger.info "#{self.class}: Notifying User #{user.id} about expiring soon ssh key(s)"

      keys = user.expiring_soon_and_unnotified_keys

      Keys::ExpiryNotificationService.new(user, { keys: keys, expiring_soon: true }).execute
    end
  end
  # rubocop:enable CodeReuse/ActiveRecord
end