fix(data): update closing_reason to other if no replaced_by_procedure_id

This commit is contained in:
Eric Leroy-Terquem 2024-03-19 16:41:02 +01:00
parent e55531c6f4
commit 234f0d7a75
2 changed files with 40 additions and 0 deletions

View file

@ -0,0 +1,17 @@
# frozen_string_literal: true
module Maintenance
class UpdateClosingReasonIfNoReplacedByIdTask < MaintenanceTasks::Task
def collection
Procedure
.with_discarded
.closes
.where(closing_reason: Procedure.closing_reasons.fetch(:internal_procedure))
.where(replaced_by_procedure_id: nil)
end
def process(procedure)
procedure.update!(closing_reason: Procedure.closing_reasons.fetch(:other))
end
end
end