Skip to content

Commit

Permalink
Add temp rake task to fix data integrity issues
Browse files Browse the repository at this point in the history
Somehow energy-company-obligation and manage-your-tax-credits have ended
up with Artefacts with kind "completed_transaction", even though their
editions are Answer and Transaction (note _not_ CompletedTransaction).

This prevents the editions from being published, because the artefacts
are not valid because their slugs don't begin with "done/"

We ran equivalent code to this rake task in integration which appears to
have fixed the issues. We'll test again in staging before running in
production.

https://govuk.zendesk.com/agent/tickets/5819067
  • Loading branch information
richardTowers committed May 2, 2024
1 parent 47f0f6b commit 0ba8e3a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/tasks/tmp_zendesk_5819067.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace :tmp_zendesk_5819067 do
desc "Fix a couple of artefacts which have the wrong 'kind'"
task fix_artefact_kinds: :environment do
eco = Artefact.find_by(slug: "energy-company-obligation")
if eco.latest_edition.class == AnswerEdition && eco.kind != "answer"

Check failure on line 5 in lib/tasks/tmp_zendesk_5819067.rake

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/ClassEqualityComparison: Use `instance_of?(AnswerEdition)` instead of comparing classes. (https://rubystyle.guide#instance-of-vs-class-comparison)
eco.kind = "answer"
eco.save!
else
puts "Skipping energy-company-obligation - had kind #{eco.kind} and latest edition class #{eco.latest_edition.class}"
end

mytc = Artefact.find_by(slug: "manage-your-tax-credits")
if mytc.latest_edition.class == TransactionEdition && mytc.kind != "transaction"

Check failure on line 13 in lib/tasks/tmp_zendesk_5819067.rake

View workflow job for this annotation

GitHub Actions / Lint Ruby / Run RuboCop

Style/ClassEqualityComparison: Use `instance_of?(TransactionEdition)` instead of comparing classes. (https://rubystyle.guide#instance-of-vs-class-comparison)
mytc.kind = "transaction"
mytc.save!
else
puts "Skipping manage-your-tax-credits - had kind #{mytc.kind} and latest edition class #{mytc.latest_edition.class}"
end
end
end

0 comments on commit 0ba8e3a

Please sign in to comment.