0
0
Fork 0

Add age/expiry duration constants to BulkImport class (#32839)

This commit is contained in:
Matt Jankowski 2024-11-12 03:57:06 -05:00 committed by GitHub
parent 897cb1803e
commit 5d9dde3ec0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 56 additions and 2 deletions

View file

@ -21,6 +21,9 @@
class BulkImport < ApplicationRecord
self.inheritance_column = false
ARCHIVE_PERIOD = 1.week
CONFIRM_PERIOD = 10.minutes
belongs_to :account
has_many :rows, class_name: 'BulkImportRow', inverse_of: :bulk_import, dependent: :delete_all
@ -42,6 +45,9 @@ class BulkImport < ApplicationRecord
validates :type, presence: true
scope :archival_completed, -> { where(created_at: ..ARCHIVE_PERIOD.ago) }
scope :confirmation_missed, -> { state_unconfirmed.where(created_at: ..CONFIRM_PERIOD.ago) }
def self.progress!(bulk_import_id, imported: false)
# Use `increment_counter` so that the incrementation is done atomically in the database
BulkImport.increment_counter(:processed_items, bulk_import_id)