-
Notifications
You must be signed in to change notification settings - Fork 1
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
[CPDNPQ-2270] port rake file and service from ECF (bulk script for revert to pending) #2025
base: main
Are you sure you want to change the base?
Conversation
Review app deployed to https://npq-registration-review-2025-web.test.teacherservices.cloud/ |
e5b4d4b
to
e07b074
Compare
e07b074
to
24552bd
Compare
24552bd
to
3639178
Compare
3639178
to
bb5b35f
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.
Couple of minor code clarity suggestions but looks great 🙌
result = application_ecf_ids.each_with_object({}) do |application_ecf_id, hash| | ||
application = Application.find_by(ecf_id: application_ecf_id) | ||
revert_to_pending = Applications::RevertToPending.new(application:, change_status_to_pending: "yes") | ||
success = application && revert_to_pending.revert |
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.
Super minor but RevertToPending already validates presence of application
?
return "Not found" if application.nil? | ||
return "Changed to pending" if success | ||
|
||
errors.map(&:message).join(", ") |
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.
errors.full_messages.to_sentence
?
@@ -0,0 +1,35 @@ | |||
# frozen_string_literal: true | |||
|
|||
require "rake" |
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 don't think this should be needed?
dry_run = args[:dry_run] != "false" | ||
unless File.exist?(csv_file_path) | ||
logger.error "File not found: #{csv_file_path}" | ||
return |
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.
exit(1)
?
application_ecf_ids = CSV.read(csv_file_path, headers: false).flatten | ||
|
||
logger.info "Bulk changing #{application_ecf_ids.size} applications to pending#{' (dry run)' 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.
sleep(10)
- gives the developer time to think 'oops' and press ctrl-c ? Might be belt and braces though, there's already a dry run feature? thoughts?
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 think this one might be overkill.
I'd expect the developer will already run this with dry-run first, and the effort in creating/uploading the CSV file in the first place means it shouldn't be a trivial thing to run accidentally.
end | ||
|
||
context "when dry run true" do | ||
subject { Rake::Task["one_off:bulk_change_to_pending"].invoke(csv_file.path, "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.
subject(:run_task)
subject { Rake::Task["one_off:bulk_change_to_pending"].invoke(csv_file.path, "true") } | ||
|
||
it "does not update any applications" do | ||
subject |
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.
run_task
? Clarifies what subject is doing ?
Quality Gate passedIssues Measures |
Context
Ticket: https://dfedigital.atlassian.net/browse/CPDNPQ-2270
bulk script for revert to pending - rake file and service ported from ECF - updated to work with the NPQ
Applications::RevertToPending
service.