-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AP-5699 Fix incorrect PDA data #7591
base: main
Are you sure you want to change the base?
Conversation
lib/tasks/fixes/ap_5699.rake
Outdated
# Transfer provider LLARNI from firm POTTER DERBY LTD to WACE MORGAN SOLICITORS | ||
Rake::Task["pda:provider_transfer_firm"].invoke("701c89c5-8672-4fd3-997c-a08a08a1cc7c", "2eee972d-4697-480f-be61-29e339bf9945") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already looks like llarni is in the firm WACE MORGAN SOLICITORS on production
laa-apply-for-legal-aid(prod)> Provider.find_by(id: "701c89c5-8672-4fd3-997c-a08a08a1cc7c").firm.name
=> "WACE MORGAN SOLICITORS"
lib/tasks/fixes/ap_5699.rake
Outdated
Rake::Task["pda:laa_transfer_office"].invoke("992c3763-6087-405d-bb0f-be46c24e0b57", "2a7babf2-d080-4181-b395-0244542ff54a") | ||
|
||
# Transfer provider DSYKES from firm CAROLE BURGHER SOLICITORS to BUTCHER & BARLOW LLP | ||
Rake::Task["pda:provider_transfer_firm"].invoke("992c3763-6087-405d-bb0f-be46c24e0b57", "2a7babf2-d080-4181-b395-0244542ff54a") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this provider is already in the correct firm
Provider.find_by(id: "992c3763-6087-405d-bb0f-be46c24e0b57").firm.name
=> "BUTCHER & BARLOW LLP"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So some unnecessary albeit unharmful actions are in there, but also some ids are wrong and will fail.
It might be good to have a dry run argument that defaults to true so that it cannot be run by mistake.
101e676
to
0643d8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reckon the dry_run naming needs some clarity but, for safety, it might be better to use != "false"
as you have done
dry_run = args[:dry_run].to_s.downcase.strip != "false"
# rathar than
dry_run = args[:dry_run].to_s.downcase.strip == "true"
But the actual updates need to use unless
not if
gaurd clauses, for example
laa.update!(office: office) unless dry_run
Might be good to test the reusable tasks as discussed in tech time
lib/tasks/pda/pda_migrations.rake
Outdated
if laa | ||
Rails.logger.info "LegalAidApplication (#{laa.application_ref}) current office code: #{laa.office.code}" | ||
|
||
laa.update!(office: office) if dry_run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming wise I would expect do_something unless dry_run
lib/tasks/fixes/ap_5699.rake
Outdated
namespace :fixes do | ||
desc "Fixes for AP-5699" | ||
task :ap_5699, [:dry_run] => :environment do |_task, args| | ||
args.with_defaults(dry_run: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All args are strings in rake i believe
args.with_defaults(dry_run: true) | |
args.with_defaults(dry_run: "true") |
lib/tasks/fixes/ap_5699.rake
Outdated
desc "Fixes for AP-5699" | ||
task :ap_5699, [:dry_run] => :environment do |_task, args| | ||
args.with_defaults(dry_run: true) | ||
dry_run = args[:dry_run] != "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dry_run = args[:dry_run].to_s.downcase.strip == "true"
lib/tasks/fixes/ap_5699.rake
Outdated
|
||
# Transfer applications from POTTER DERBY LTD office 0M434D to WACE MORGAN SOLICITORS office 0H036Y | ||
potter_derby_application_ids.each do |appid| | ||
Rake::Task["pda:laa_transfer_office"].execute(dry_run: dry_run.to_s, appid: appid, officeid: "c2d4f6df-0a06-4ade-b1c8-1bba1406a874") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be needed once dry run default is set i think
Rake::Task["pda:laa_transfer_office"].execute(dry_run: dry_run.to_s, appid: appid, officeid: "c2d4f6df-0a06-4ade-b1c8-1bba1406a874") | |
Rake::Task["pda:laa_transfer_office"].execute(dry_run: dry_run, appid: appid, officeid: "c2d4f6df-0a06-4ade-b1c8-1bba1406a874") |
lib/tasks/fixes/ap_5699.rake
Outdated
Rake::Task["pda:laa_transfer_office"].execute(dry_run: dry_run.to_s, appid: "6db37c7a-7350-4384-aa2d-c6a6ccfc22e9", officeid: "fe5dfac8-baa6-4a22-b0c9-681d97068508") | ||
|
||
# Delete the firm and offices of CAROLE BURGHER SOLICITORS | ||
Rake::Task["pda:delete_firm_office"].execute(dry_run: dry_run.to_s, firmid: "29bbd5ca-5820-4502-b74a-76b11e8bff64") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to_s not be needed once dry run default is set to a string i think
lib/tasks/fixes/ap_5699.rake
Outdated
Rails.logger.info "Start of HAZELBACON" | ||
|
||
# Transfer provider HAZELBACON from firm MCARAS to CANTER LEVIN & BERG LTD, Office: 5T620Z | ||
Rake::Task["pda:provider_transfer_firm"].execute(dry_run: dry_run.to_s, providerid: "03ec8aa6-56a4-494d-91e6-88d4974671db", firmid: "02e2f920-c5fd-4e6c-9d6c-af1a16dfe7fc") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to_s not be needed once dry run default is set to a string i think
lib/tasks/pda/pda_migrations.rake
Outdated
namespace :pda do | ||
desc "Transfer a LegalAidApplication from one Office to another" | ||
task :laa_transfer_office, %i[dry_run appid officeid] => :environment do |_task, args| | ||
args.with_defaults(dry_run: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args.with_defaults(dry_run: true) | |
args.with_defaults(dry_run: "true") |
lib/tasks/pda/pda_migrations.rake
Outdated
desc "Transfer a LegalAidApplication from one Office to another" | ||
task :laa_transfer_office, %i[dry_run appid officeid] => :environment do |_task, args| | ||
args.with_defaults(dry_run: true) | ||
dry_run = args[:dry_run] != "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dry_run = args[:dry_run] != "false" | |
dry_run = args[:dry_run].to_s.downcase.strip == "true" |
lib/tasks/pda/pda_migrations.rake
Outdated
|
||
desc "Transfer a Provider from one Firm to another" | ||
task :provider_transfer_firm, %i[dry_run providerid firmid] => :environment do |_task, args| | ||
args.with_defaults(dry_run: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args.with_defaults(dry_run: true) | |
args.with_defaults(dry_run: "true") |
lib/tasks/pda/pda_migrations.rake
Outdated
desc "Transfer a Provider from one Firm to another" | ||
task :provider_transfer_firm, %i[dry_run providerid firmid] => :environment do |_task, args| | ||
args.with_defaults(dry_run: true) | ||
dry_run = args[:dry_run] != "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dry_run = args[:dry_run] != "false" | |
dry_run = args[:dry_run].to_s.downcase.strip == "true" |
e267472
to
82613ee
Compare
- Task to transfer the selected office of an application - Task to transfer a provider to a different firm - Task to remove unused Firm
- Cleanup incorrect PDA data
236061b
to
60a820a
Compare
60a820a
to
7f4ab3a
Compare
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some nits and some other comments
firm = Firm.find_by(id: args[:firmid]) | ||
|
||
if firm.nil? | ||
Rails.logger.info "FIRM does not exists" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: exists
should say exist
end | ||
end | ||
|
||
context "when LegalAidApplication does not exist" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth adding an expect
to verify that office doesn't change in these scenarios?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say yes, it's worth it - this could be destructive if it goes wrong! 😬
end | ||
end | ||
|
||
context "when Provider does not exist" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth adding an expect
to verify that provider doesn't change in these scenarios?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
let(:firm) { create(:firm) } | ||
let(:office) { create(:office) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: As these are only used in the final spec, could they be defined within it?
@@ -0,0 +1,86 @@ | |||
namespace :ptr_migrations do | |||
desc "Transfer a LegalAidApplication from one Office to another" | |||
task :laa_transfer_office, %i[mock appid officeid] => :environment do |_task, args| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Could these be called app_id
and office_id
for readability?
|
||
it "skips deleting the Office and logs a message" do | ||
expect(Rails.logger).to receive(:info).with("Firm (#{firm.name}), Office (#{office.code}) has 1 legal aid application associated with it. Skipping!") | ||
expect(Rails.logger).to receive(:info).with("Firm (#{firm.name}) has 1 office associated with it. Skipping!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to work when there are multiple offices? Could there a be a test for this scenario?
|
||
if applications_in_office.positive? | ||
Rails.logger.info "Firm (#{firm.name}), Office (#{office.code}) has #{applications_in_office} legal aid application associated with it. Skipping!" | ||
# next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented out next
end | ||
|
||
desc "Transfer a Provider from one Firm to another" | ||
task :provider_transfer_firm, %i[mock providerid firmid] => :environment do |_task, args| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto nit: clarity of names
task :provider_transfer_firm, %i[mock providerid firmid] => :environment do |_task, args| | |
task :provider_transfer_firm, %i[mock provider_id firm_id] => :environment do |_task, args| |
What
Link to story
The new PDA added Provider to incorrect firms and therefore office.
A few new firms where then created because of the above.
This is to transfer application to the correct office; providers to the correct firms; and to remove Firms where no providers have been onboarded.
Checklist
Before you ask people to review this PR:
bundle exec rake
git rebase main
.