update termine_close_to_expiration with traitement
This commit is contained in:
parent
8f9d6d2871
commit
9b6c5fd7fd
2 changed files with 10 additions and 4 deletions
|
@ -199,10 +199,9 @@ 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
|
||||
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 })
|
||||
def self.termine_close_to_expiration
|
||||
dossier_ids = Traitement.termine_close_to_expiration.pluck(:dossier_id).uniq
|
||||
Dossier.where(id: dossier_ids)
|
||||
end
|
||||
|
||||
scope :brouillon_expired, -> do
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
class Traitement < ApplicationRecord
|
||||
belongs_to :dossier
|
||||
belongs_to :instructeur
|
||||
|
||||
scope :termine_close_to_expiration, -> do
|
||||
joins(dossier: :procedure)
|
||||
.where(state: Dossier::TERMINE)
|
||||
.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
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue