fix(export): when it takes more than 3 hours, exports are purge before being generated. make it possible to have an export that takes more than 3 hours and share this behaviour with kind of same class archive

This commit is contained in:
Martin 2022-07-07 18:15:48 +02:00
parent 051e912a91
commit 3e56fdd1d7
19 changed files with 106 additions and 70 deletions

View file

@ -4,6 +4,7 @@
#
# id :bigint not null, primary key
# format :string not null
# job_status :string
# key :text not null
# procedure_presentation_snapshot :jsonb
# statut :string default("tous")
@ -13,7 +14,9 @@
# procedure_presentation_id :bigint
#
class Export < ApplicationRecord
MAX_DUREE_CONSERVATION_EXPORT = 3.hours
include TransientModelsWithPurgeableJobConcern
MAX_DUREE_CONSERVATION_EXPORT = 16.hours
enum format: {
csv: 'csv',
@ -69,10 +72,6 @@ class Export < ApplicationRecord
time_span_type == Export.time_span_types.fetch(:monthly) ? 30.days.ago : nil
end
def ready?
file.attached?
end
def old?
updated_at < 20.minutes.ago || filters_changed?
end