Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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é #9797

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions app/jobs/reset_expiring_dossiers_job.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
class ResetExpiringDossiersJob < ApplicationJob
def perform(procedure)
procedure.dossiers
.where.not(brouillon_close_to_expiration_notice_sent_at: nil)
.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))
procedure
.dossiers
.in_batches do |relation|
relation.update_all(brouillon_close_to_expiration_notice_sent_at: nil,
en_construction_close_to_expiration_notice_sent_at: nil,
termine_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,
termine_close_to_expiration_notice_sent_at: nil)
end
end
end
end
end
8 changes: 8 additions & 0 deletions app/models/dossier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,14 @@ def user_email_for(use)
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
if termine?
traitement&.motivation || read_attribute(:motivation)
Expand Down