From e9b80ed023773750dcf36f42435a2c3f8c05390a Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 20 Feb 2024 11:50:37 +0100 Subject: [PATCH] data(fix): invalid monavis links --- ...0240220104123_disable_invalid_monavis.rake | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/tasks/deployment/20240220104123_disable_invalid_monavis.rake diff --git a/lib/tasks/deployment/20240220104123_disable_invalid_monavis.rake b/lib/tasks/deployment/20240220104123_disable_invalid_monavis.rake new file mode 100644 index 000000000..9e587f58c --- /dev/null +++ b/lib/tasks/deployment/20240220104123_disable_invalid_monavis.rake @@ -0,0 +1,23 @@ +namespace :after_party do + desc 'Deployment task: disable_invalid_monavis' + task disable_invalid_monavis: :environment do + puts "Running deploy task 'disable_invalid_monavis'" + # rubocop:disable DS/Unscoped + all_procedures = Procedure.unscoped.where.not(monavis_embed: nil) + # rubocop:enable DS/Unscoped + progress = ProgressReport.new(all_procedures.count) + + all_procedures.find_each do |procedure| + if !procedure.valid? && procedure.errors.key?(:monavis_embed) + procedure.update_column(:monavis_embed, '') + rake_puts "fix: #{procedure.id}" + end + progress.inc(1) + end + progress.finish + # 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