about summary refs log tree commit diff
path: root/app/workers/scheduler/feed_cleanup_scheduler.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/workers/scheduler/feed_cleanup_scheduler.rb')
-rw-r--r--app/workers/scheduler/feed_cleanup_scheduler.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/workers/scheduler/feed_cleanup_scheduler.rb b/app/workers/scheduler/feed_cleanup_scheduler.rb
new file mode 100644
index 000000000..c7df363a4
--- /dev/null
+++ b/app/workers/scheduler/feed_cleanup_scheduler.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+require 'sidekiq-scheduler'
+
+class Scheduler::FeedCleanupScheduler
+  include Sidekiq::Worker
+
+  def perform
+    logger.info 'Cleaning out home feeds of inactive users'
+
+    redis.pipelined do
+      inactive_users.pluck(:account_id).each do |account_id|
+        redis.del(FeedManager.instance.key(:home, account_id))
+      end
+    end
+  end
+
+  private
+
+  def inactive_users
+    User.confirmed.where('current_sign_in_at < ?', 14.days.ago)
+  end
+
+  def redis
+    Redis.current
+  end
+end