about summary refs log tree commit diff
path: root/app/workers/scheduler/feed_cleanup_scheduler.rb
blob: 402eed7c6f7b69c0abf99b5d894852180cf19ebf (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
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.inactive
  end

  def redis
    Redis.current
  end
end