about summary refs log tree commit diff
path: root/app/workers/scheduler/feed_cleanup_scheduler.rb
blob: 222f5ed84f27a7e974063f73708f3cb70a1feea9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true
require 'sidekiq-scheduler'

class Scheduler::FeedCleanupScheduler
  include Sidekiq::Worker

  def perform
    redis.pipelined do
      inactive_users.each do |account_id|
        redis.del(FeedManager.instance.key(:home, account_id))
        redis.del(FeedManager.instance.key(:home, account_id, 'reblogs'))
      end
    end
  end

  private

  def inactive_users
    @inactive_users ||= User.confirmed.inactive.pluck(:account_id)
  end

  def redis
    Redis.current
  end
end