correctif(ResetExpiringDossiersJob): timeout sur la prod, utilise une requete plus générique mais plus rapide [on ne scope pas aux dossiers ayant ete notifies, on les reset tous car ca timeouté
This commit is contained in:
parent
51c5a8d0f7
commit
b0e818f8f1
2 changed files with 17 additions and 7 deletions
|
@ -1,13 +1,15 @@
|
||||||
class ResetExpiringDossiersJob < ApplicationJob
|
class ResetExpiringDossiersJob < ApplicationJob
|
||||||
def perform(procedure)
|
def perform(procedure)
|
||||||
procedure.dossiers
|
procedure
|
||||||
.where.not(brouillon_close_to_expiration_notice_sent_at: nil)
|
.dossiers
|
||||||
.or(Dossier.where.not(en_construction_close_to_expiration_notice_sent_at: nil))
|
|
||||||
.or(Dossier.where.not(termine_close_to_expiration_notice_sent_at: nil))
|
|
||||||
.in_batches do |relation|
|
.in_batches do |relation|
|
||||||
relation.update_all(brouillon_close_to_expiration_notice_sent_at: nil,
|
relation.each do |dossier|
|
||||||
|
if dossier.expiration_started?
|
||||||
|
dossier.update(brouillon_close_to_expiration_notice_sent_at: nil,
|
||||||
en_construction_close_to_expiration_notice_sent_at: nil,
|
en_construction_close_to_expiration_notice_sent_at: nil,
|
||||||
termine_close_to_expiration_notice_sent_at: nil)
|
termine_close_to_expiration_notice_sent_at: nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -484,6 +484,14 @@ class Dossier < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def expiration_started?
|
||||||
|
[
|
||||||
|
brouillon_close_to_expiration_notice_sent_at,
|
||||||
|
en_construction_close_to_expiration_notice_sent_at,
|
||||||
|
termine_close_to_expiration_notice_sent_at
|
||||||
|
].any?(&:present?)
|
||||||
|
end
|
||||||
|
|
||||||
def motivation
|
def motivation
|
||||||
if termine?
|
if termine?
|
||||||
traitement&.motivation || read_attribute(:motivation)
|
traitement&.motivation || read_attribute(:motivation)
|
||||||
|
|
Loading…
Reference in a new issue