Add retention policy for cached content and media (#19232)
This commit is contained in:
parent
3e0999cd11
commit
5c9abdeff1
30 changed files with 559 additions and 135 deletions
25
app/lib/vacuum/backups_vacuum.rb
Normal file
25
app/lib/vacuum/backups_vacuum.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Vacuum::BackupsVacuum
|
||||
def initialize(retention_period)
|
||||
@retention_period = retention_period
|
||||
end
|
||||
|
||||
def perform
|
||||
vacuum_expired_backups! if retention_period?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def vacuum_expired_backups!
|
||||
backups_past_retention_period.in_batches.destroy_all
|
||||
end
|
||||
|
||||
def backups_past_retention_period
|
||||
Backup.unscoped.where(Backup.arel_table[:created_at].lt(@retention_period.ago))
|
||||
end
|
||||
|
||||
def retention_period?
|
||||
@retention_period.present?
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue