diff --git a/Gemfile.saas.lock b/Gemfile.saas.lock index 1c45027ec..8de89e1fb 100644 --- a/Gemfile.saas.lock +++ b/Gemfile.saas.lock @@ -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 diff --git a/app/models/account/import.rb b/app/models/account/import.rb index c5e6896cf..ea34bf145 100644 --- a/app/models/account/import.rb +++ b/app/models/account/import.rb @@ -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 diff --git a/config/recurring.yml b/config/recurring.yml index 981511d45..209d8fed4 100644 --- a/config/recurring.yml +++ b/config/recurring.yml @@ -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