gitlab-org--gitlab-foss/app/workers/use_key_worker.rb
Vincent Wong b6df93a51f Record and show last used date of SSH Keys
Addresses: Issue #13810

1. Adds a last_used_at attribute to the Key table/model
2. Update a key's last_used_at whenever it gets used
3. Display how long ago an ssh key was last used
2017-01-09 04:15:39 +11:00

13 lines
305 B
Ruby

class UseKeyWorker
include Sidekiq::Worker
include DedicatedSidekiqQueue
def perform(key_id)
key = Key.find(key_id)
key.touch(:last_used_at)
rescue ActiveRecord::RecordNotFound
Rails.logger.error("UseKeyWorker: couldn't find key with ID=#{key_id}, skipping job")
false
end
end