fix attestation templates
This commit is contained in:
parent
4e7733e571
commit
80125cbed1
1 changed files with 19 additions and 0 deletions
19
lib/tasks/fix_attestations.rake
Normal file
19
lib/tasks/fix_attestations.rake
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
namespace :hotfix do
|
||||||
|
desc 'Fix attestation templates'
|
||||||
|
task attestation_templates: :environment do
|
||||||
|
attestation_templates = Rails.root.join('lib', 'tasks', 'attestation_templates.json')
|
||||||
|
file = File.read attestation_templates
|
||||||
|
json = JSON.parse file
|
||||||
|
progress = ProgressReport.new(json.size)
|
||||||
|
|
||||||
|
json.each do |row|
|
||||||
|
attestation_template = AttestationTemplate.find_by(id: row['id'])
|
||||||
|
procedure = Procedure.find_by(id: row['procedure_id'])
|
||||||
|
if attestation_template.present? && procedure.present?
|
||||||
|
attestation_template.update_column(:procedure_id, procedure.id)
|
||||||
|
end
|
||||||
|
progress.inc
|
||||||
|
end
|
||||||
|
progress.finish
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue