Skip to content
Snippets Groups Projects
Commit f391a467 authored by Eugen Rochko's avatar Eugen Rochko Committed by GitHub
Browse files

Periodically remove expired PuSH subscribers (#4654)

parent 143b77e1
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@ class Subscription < ApplicationRecord
scope :confirmed, -> { where(confirmed: true) }
scope :future_expiration, -> { where(arel_table[:expires_at].gt(Time.now.utc)) }
scope :expired, -> { where(arel_table[:expires_at].lt(Time.now.utc)) }
scope :active, -> { confirmed.future_expiration }
def lease_seconds=(value)
......
......@@ -5,8 +5,6 @@ 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))
......
......@@ -5,7 +5,6 @@ class Scheduler::MediaCleanupScheduler
include Sidekiq::Worker
def perform
logger.info 'Cleaning out unattached media attachments'
unattached_media.find_each(&:destroy)
end
......
# frozen_string_literal: true
require 'sidekiq-scheduler'
class Scheduler::SubscriptionsCleanupScheduler
include Sidekiq::Worker
def perform
Subscription.expired.in_batches.delete_all
end
end
......@@ -7,7 +7,6 @@ class Scheduler::SubscriptionsScheduler
include Sidekiq::Worker
def perform
logger.info 'Queueing PuSH re-subscriptions'
Pubsubhubbub::SubscribeWorker.push_bulk(expiring_accounts.pluck(:id))
end
......
......@@ -21,3 +21,6 @@
user_cleanup_scheduler:
cron: '4 5 * * *'
class: Scheduler::UserCleanupScheduler
subscriptions_cleanup_scheduler:
cron: '2 2 * * 0'
class: Scheduler::SubscriptionsCleanupScheduler
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment