Specs for cleanup workers (#3235)
* Add spec files for feed and media cleanup workers * Add coverage for feed and media cleanup schedulers * Clean up feed and media cleanup workers
This commit is contained in:
parent
4a4733b397
commit
ec34ec63b1
6 changed files with 39 additions and 2 deletions
|
@ -55,6 +55,7 @@ class MediaAttachment < ApplicationRecord
|
|||
validates :account, presence: true
|
||||
|
||||
scope :attached, -> { where.not(status_id: nil) }
|
||||
scope :unattached, -> { where(status_id: nil) }
|
||||
scope :local, -> { where(remote_url: '') }
|
||||
default_scope { order(id: :asc) }
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
class User < ApplicationRecord
|
||||
include Settings::Extend
|
||||
ACTIVE_DURATION = 14.days
|
||||
|
||||
devise :registerable, :recoverable,
|
||||
:rememberable, :trackable, :validatable, :confirmable,
|
||||
|
@ -51,6 +52,7 @@ class User < ApplicationRecord
|
|||
scope :recent, -> { order(id: :desc) }
|
||||
scope :admins, -> { where(admin: true) }
|
||||
scope :confirmed, -> { where.not(confirmed_at: nil) }
|
||||
scope :inactive, -> { where(arel_table[:current_sign_in_at].lt(ACTIVE_DURATION.ago)) }
|
||||
|
||||
before_validation :sanitize_languages
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class Scheduler::FeedCleanupScheduler
|
|||
private
|
||||
|
||||
def inactive_users
|
||||
User.confirmed.where('current_sign_in_at < ?', 14.days.ago)
|
||||
User.confirmed.inactive
|
||||
end
|
||||
|
||||
def redis
|
||||
|
|
|
@ -12,6 +12,6 @@ class Scheduler::MediaCleanupScheduler
|
|||
private
|
||||
|
||||
def unattached_media
|
||||
MediaAttachment.reorder(nil).where(status_id: nil).where('created_at < ?', 1.day.ago)
|
||||
MediaAttachment.reorder(nil).unattached.where('created_at < ?', 1.day.ago)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue