Merge pull request #9466 from demarches-simplifiees/track-dossiers-with-no-groupe-instructeur
Fix brouillon dossiers with forced_groupe_instructeur
This commit is contained in:
commit
6198de1f43
2 changed files with 29 additions and 1 deletions
|
@ -646,11 +646,14 @@ class Dossier < ApplicationRecord
|
|||
|
||||
previous_groupe_instructeur = self.groupe_instructeur
|
||||
|
||||
track_assigned_dossier_without_groupe_instructeur if groupe_instructeur.nil?
|
||||
|
||||
update!(groupe_instructeur:, groupe_instructeur_updated_at: Time.zone.now)
|
||||
update!(forced_groupe_instructeur: true) if mode == DossierAssignment.modes.fetch(:manual)
|
||||
|
||||
create_assignment(mode, previous_groupe_instructeur, groupe_instructeur, author&.email)
|
||||
|
||||
if !brouillon?
|
||||
create_assignment(mode, previous_groupe_instructeur, groupe_instructeur, author&.email)
|
||||
unfollow_stale_instructeurs
|
||||
if author.present?
|
||||
log_dossier_operation(author, :changer_groupe_instructeur, self)
|
||||
|
@ -1415,4 +1418,13 @@ class Dossier < ApplicationRecord
|
|||
|
||||
logger.info payload.to_json
|
||||
end
|
||||
|
||||
def track_assigned_dossier_without_groupe_instructeur
|
||||
Sentry.capture_message(
|
||||
"Assigned dossier without groupe_instructeur",
|
||||
extra: {
|
||||
dossier_id: self.id
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: update_brouillon_dossiers_with_forced_groupe_instructeur'
|
||||
task update_brouillon_dossiers_with_forced_groupe_instructeur: :environment do
|
||||
puts "Running deploy task 'update_brouillon_dossiers_with_forced_groupe_instructeur'"
|
||||
|
||||
# Put your task implementation HERE.
|
||||
dossiers_to_fix = Dossier.where(state: :brouillon).where(forced_groupe_instructeur: true).where(groupe_instructeur_id: nil)
|
||||
|
||||
dossiers_to_fix.update_all(forced_groupe_instructeur: false)
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord
|
||||
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue