diff options
author | Vincent Wong <wingyu64@gmail.com> | 2016-12-21 17:59:54 +0300 |
---|---|---|
committer | Vincent Wong <wingyu64@gmail.com> | 2017-01-08 20:15:39 +0300 |
commit | b6df93a51f90c7ed29ce6667c6b1a8debf02506e (patch) | |
tree | ff13ffc730ceeb52635bad3204db1050d0e74947 /app/workers | |
parent | f264ec6ee74a0263b4e5212e921c4638c25f8fcd (diff) |
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
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/use_key_worker.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/workers/use_key_worker.rb b/app/workers/use_key_worker.rb new file mode 100644 index 00000000000..c9d382cc5d6 --- /dev/null +++ b/app/workers/use_key_worker.rb @@ -0,0 +1,13 @@ +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 |