2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-07-02 11:02:50 +02:00
|
|
|
class Traitement < ApplicationRecord
|
2020-07-20 17:04:05 +02:00
|
|
|
belongs_to :dossier, optional: false
|
2021-11-04 19:05:04 +01:00
|
|
|
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
|
2021-06-16 10:51:56 +02:00
|
|
|
includes(:dossier)
|
2021-11-04 19:05:04 +01:00
|
|
|
.termine
|
2023-02-23 13:13:01 +01:00
|
|
|
.where(dossier: procedure.dossiers.visible_by_administration)
|
2023-04-19 11:27:46 +02:00
|
|
|
.where.not('dossiers.depose_at' => nil)
|
|
|
|
.where.not(processed_at: nil)
|
2021-06-16 10:51:56 +02:00
|
|
|
.order(:processed_at)
|
|
|
|
end
|
2023-10-17 12:00:16 +02:00
|
|
|
|
|
|
|
def browser=(browser)
|
|
|
|
if browser == 'api'
|
|
|
|
self.browser_name = browser
|
|
|
|
self.browser_version = 2
|
|
|
|
self.browser_supported = true
|
|
|
|
elsif browser.present?
|
|
|
|
self.browser_name = browser.name
|
|
|
|
self.browser_version = browser.version
|
|
|
|
self.browser_supported = BrowserSupport.supported?(browser)
|
|
|
|
end
|
|
|
|
end
|
2024-11-21 18:38:28 +01:00
|
|
|
|
|
|
|
def termine? = state.in?(Dossier::TERMINE)
|
2020-07-02 11:02:50 +02:00
|
|
|
end
|