From cfdc6b2d0ddb0bb2c3806f9e39ccd6d2be784146 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Tue, 11 Dec 2018 14:44:31 -0600 Subject: [PATCH] Add new cron job for clearing expired source tokens. Closes #121. --- lib/scheduled_jobs.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/scheduled_jobs.rb b/lib/scheduled_jobs.rb index 35aac082..3d4f992d 100644 --- a/lib/scheduled_jobs.rb +++ b/lib/scheduled_jobs.rb @@ -100,4 +100,12 @@ module ScheduledJobs end end + def self.delete_expired_source_tokens + return Enumerator.new do |yielder| + yielder << lambda do + tokens_deleted = SourceToken.where("expiration > ?", DateTime.now - 1.day).delete_all + "Deleted #{tokens_deleted} source tokens" + end + end + end end