demarches-normaliennes/app/models/traitement.rb

17 lines
584 B
Ruby
Raw Normal View History

class Traitement < ApplicationRecord
belongs_to :dossier, optional: false
scope :en_construction, -> { where(state: Dossier.states.fetch(:en_construction)) }
scope :en_instruction, -> { where(state: Dossier.states.fetch(:en_instruction)) }
scope :termine, -> { where(state: Dossier::TERMINE) }
2021-06-16 15:13:36 +02:00
scope :for_traitement_time_stats, -> (procedure) do
includes(:dossier)
.termine
.where(dossier: procedure.dossiers.visible_by_administration)
.where.not('dossiers.depose_at' => nil)
.where.not(processed_at: nil)
.order(:processed_at)
end
end