change scope to include new column for expiring dossiers

This commit is contained in:
Lisa Durand 2024-07-17 15:42:26 +02:00
parent 0dcdcb5643
commit eb3b928cf2
No known key found for this signature in database
GPG key ID: 0DF91F2CA1E8B816
2 changed files with 5 additions and 4 deletions

View file

@ -367,9 +367,10 @@ class Dossier < ApplicationRecord
scope :without_termine_expiration_notice_sent, -> { where(termine_close_to_expiration_notice_sent_at: nil) } scope :without_termine_expiration_notice_sent, -> { where(termine_close_to_expiration_notice_sent_at: nil) }
scope :deleted_by_user_expired, -> { where('dossiers.hidden_by_user_at < ?', 1.week.ago) } scope :deleted_by_user_expired, -> { where('dossiers.hidden_by_user_at < ?', 1.week.ago) }
scope :deleted_by_administration_expired, -> { where('dossiers.hidden_by_administration_at < ?', 1.week.ago) } scope :deleted_by_administration_expired, -> { where('dossiers.hidden_by_administration_at < ?', 1.week.ago) }
scope :en_brouillon_expired_to_delete, -> { state_brouillon.deleted_by_user_expired } scope :deleted_by_automatic_expired, -> { where('dossiers.hidden_by_expired_at < ?', 1.week.ago) }
scope :en_construction_expired_to_delete, -> { state_en_construction.deleted_by_user_expired } scope :en_brouillon_expired_to_delete, -> { state_brouillon.deleted_by_user_expired.or(state_brouillon.deleted_by_automatic_expired) }
scope :termine_expired_to_delete, -> { state_termine.deleted_by_user_expired.deleted_by_administration_expired } scope :en_construction_expired_to_delete, -> { state_en_construction.deleted_by_user_expired.or(state_en_construction.deleted_by_automatic_expired) }
scope :termine_expired_to_delete, -> { state_termine.deleted_by_user_expired.deleted_by_administration_expired.or(state_termine.deleted_by_automatic_expired) }
scope :brouillon_near_procedure_closing_date, -> do scope :brouillon_near_procedure_closing_date, -> do
# select users who have submitted dossier for the given 'procedures.id' # select users who have submitted dossier for the given 'procedures.id'

View file

@ -10,7 +10,7 @@ RSpec.describe Cron::DiscardedDossiersDeletionJob, type: :job do
dossier.send(:log_dossier_operation, instructeur, :supprimer, dossier) dossier.send(:log_dossier_operation, instructeur, :supprimer, dossier)
dossier.update_columns(hidden_by_user_at: hidden_at, hidden_by_administration_at: hidden_at) dossier.update_columns(hidden_by_user_at: hidden_at, hidden_by_administration_at: hidden_at)
dossier.update_column(:hidden_by_reason, "user_request") dossier.update_column(:hidden_by_reason, "user_request")
dossier_2.update_columns(hidden_by_user_at: hidden_at, hidden_by_administration_at: hidden_at) dossier_2.update_columns(hidden_by_expired_at: hidden_at)
dossier_2.update_column(:hidden_by_reason, "expired") dossier_2.update_column(:hidden_by_reason, "expired")
end end