2020-08-06 16:35:45 +02:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: traitements
|
|
|
|
#
|
|
|
|
# id :bigint not null, primary key
|
|
|
|
# instructeur_email :string
|
|
|
|
# motivation :string
|
|
|
|
# processed_at :datetime
|
|
|
|
# state :string
|
|
|
|
# dossier_id :bigint
|
|
|
|
#
|
2020-07-02 11:02:50 +02:00
|
|
|
class Traitement < ApplicationRecord
|
2020-07-20 17:04:05 +02:00
|
|
|
belongs_to :dossier, optional: false
|
2020-07-06 22:13:00 +02:00
|
|
|
|
|
|
|
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
|
2020-07-02 11:02:50 +02:00
|
|
|
end
|