Add import cleanup
This commit is contained in:
+2
-1
@@ -628,6 +628,7 @@ GEM
|
||||
railties
|
||||
yabeda (~> 0.8)
|
||||
zeitwerk (2.7.4)
|
||||
zip_kit (6.3.4)
|
||||
|
||||
PLATFORMS
|
||||
aarch64-linux
|
||||
@@ -678,7 +679,6 @@ DEPENDENCIES
|
||||
rouge
|
||||
rqrcode
|
||||
rubocop-rails-omakase
|
||||
rubyzip
|
||||
selenium-webdriver
|
||||
sentry-rails
|
||||
sentry-ruby
|
||||
@@ -705,6 +705,7 @@ DEPENDENCIES
|
||||
yabeda-prometheus-mmap
|
||||
yabeda-puma-plugin
|
||||
yabeda-rails
|
||||
zip_kit
|
||||
|
||||
BUNDLED WITH
|
||||
2.7.2
|
||||
|
||||
@@ -8,6 +8,12 @@ class Account::Import < ApplicationRecord
|
||||
|
||||
enum :status, %w[ pending processing completed failed ].index_by(&:itself), default: :pending
|
||||
|
||||
scope :expired, -> { where(completed_at: ...24.hours.ago) }
|
||||
|
||||
def self.cleanup
|
||||
expired.destroy_all
|
||||
end
|
||||
|
||||
def process_later
|
||||
ImportAccountDataJob.perform_later(self)
|
||||
end
|
||||
@@ -39,7 +45,7 @@ class Account::Import < ApplicationRecord
|
||||
|
||||
private
|
||||
def mark_completed
|
||||
completed!
|
||||
update!(status: :completed, completed_at: Time.current)
|
||||
ImportMailer.completed(identity, account).deliver_later
|
||||
end
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@ production: &production
|
||||
cleanup_exports:
|
||||
command: "Export.cleanup"
|
||||
schedule: every hour at minute 20
|
||||
cleanup_imports:
|
||||
command: "Account::Import.cleanup"
|
||||
schedule: every hour at minute 25
|
||||
incineration:
|
||||
class: "Account::IncinerateDueJob"
|
||||
schedule: every 8 hours at minute 16
|
||||
|
||||
Reference in New Issue
Block a user