From 87741f4b4903bf18dba78b5c2d53d57f2e55fb8d Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Mon, 21 Oct 2019 17:14:56 +0200 Subject: [PATCH] introduce constant for exports --- app/models/procedure.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 4e14e7f94..d4703b465 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -6,6 +6,7 @@ class Procedure < ApplicationRecord include ProcedureStatsConcern MAX_DUREE_CONSERVATION = 36 + MAX_DUREE_CONSERVATION_EXPORT = 3.hours has_many :types_de_champ, -> { root.public_only.ordered }, inverse_of: :procedure, dependent: :destroy has_many :types_de_champ_private, -> { root.private_only.ordered }, class_name: 'TypeDeChamp', inverse_of: :procedure, dependent: :destroy @@ -133,15 +134,15 @@ class Procedure < ApplicationRecord end def csv_export_stale? - !csv_export_file.attached? || csv_export_file.created_at < 3.hours.ago + !csv_export_file.attached? || csv_export_file.created_at < MAX_DUREE_CONSERVATION_EXPORT.ago end def xlsx_export_stale? - !xlsx_export_file.attached? || xlsx_export_file.created_at < 3.hours.ago + !xlsx_export_file.attached? || xlsx_export_file.created_at < MAX_DUREE_CONSERVATION_EXPORT.ago end def ods_export_stale? - !ods_export_file.attached? || ods_export_file.created_at < 3.hours.ago + !ods_export_file.attached? || ods_export_file.created_at < MAX_DUREE_CONSERVATION_EXPORT.ago end def should_generate_export?(format)