fix(spec): get back to stable state
This commit is contained in:
parent
646459a1da
commit
1d721f14a0
2 changed files with 20 additions and 1 deletions
|
@ -304,10 +304,21 @@ class Dossier < ApplicationRecord
|
|||
.joins(:procedure)
|
||||
.where("dossiers.en_instruction_at + (duree_conservation_dossiers_dans_ds * INTERVAL '1 month') - INTERVAL :expires_in < :now", { now: Time.zone.now, expires_in: INTERVAL_BEFORE_EXPIRATION })
|
||||
end
|
||||
|
||||
# TODO/MFO
|
||||
# maybe reconsider `termine_close_to_expiration` implementation, but for now this implementation is missing
|
||||
# 1. the check on traitements.processed_at? -> is is replicated on dossier?
|
||||
# 2. the check on process_expired
|
||||
# scope :termine_close_to_expiration, -> do
|
||||
# state_termine
|
||||
# .joins(:procedure)
|
||||
# .where("dossiers.processed_at + (duree_conservation_dossiers_dans_ds * INTERVAL '1 month') - INTERVAL :expires_in < :now", { now: Time.zone.now, expires_in: INTERVAL_BEFORE_EXPIRATION })
|
||||
# end
|
||||
# TODO/MFO
|
||||
scope :termine_close_to_expiration, -> do
|
||||
state_termine
|
||||
.joins(:procedure)
|
||||
.where("dossiers.processed_at + (duree_conservation_dossiers_dans_ds * INTERVAL '1 month') - INTERVAL :expires_in < :now", { now: Time.zone.now, expires_in: INTERVAL_BEFORE_EXPIRATION })
|
||||
.where(id: Traitement.termine_close_to_expiration.select(:dossier_id).distinct)
|
||||
end
|
||||
|
||||
scope :brouillon_expired, -> do
|
||||
|
|
|
@ -25,6 +25,14 @@ class Traitement < ApplicationRecord
|
|||
.order(:processed_at)
|
||||
end
|
||||
|
||||
scope :termine_close_to_expiration, -> do
|
||||
joins(dossier: :procedure)
|
||||
.termine
|
||||
.where(process_expired: true)
|
||||
.where('dossiers.state' => Dossier::TERMINE)
|
||||
.where("traitements.processed_at + (procedures.duree_conservation_dossiers_dans_ds * INTERVAL '1 month') - INTERVAL :expires_in < :now", { now: Time.zone.now, expires_in: Dossier::INTERVAL_BEFORE_EXPIRATION })
|
||||
end
|
||||
|
||||
def self.count_dossiers_termines_by_month(groupe_instructeurs)
|
||||
last_traitements_per_dossier = Traitement
|
||||
.select('max(traitements.processed_at) as processed_at')
|
||||
|
|
Loading…
Reference in a new issue