-
Notifications
You must be signed in to change notification settings - Fork 19
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
Migrate ColocatedTasks to their respective subclasses #11337
Comments
This will require some degree of ongoing monitoring - be aware that code elsewhere may be relying on the existing task type. |
We should be able to remove the |
Do we want update action to nil? Maybe we can do that in a second pass, so we still have the information if we mess anything up in the first pass. Let's quickly see if we can get an idea of how many tasks this will update. Looker first: https://caseflow-looker.va.gov/sql/mrrydzw4m9pxcz
How many total? https://caseflow-looker.va.gov/sql/6ztd5225pwncpf # Let's dry run this and see how many of each type of task gets changed.
rails c> Task.where(type: ColocatedTask.name).count
# 15444
# Numbers match. Fantastico!
# First let's group by ColocatedTask action field to confirm numbers are the same
rails c> pp Task.where(type: ColocatedTask.name).group(:action).count
# {"aoj"=>616,
"missing_records"=>373,
"retired_vlj"=>22,
"ihp"=>1070,
"unaccredited_rep"=>16,
"arneson"=>93,
"new_rep_arguments"=>94,
"missing_hearing_transcripts"=>397,
"schedule_hearing"=>3209,
"pending_scanning_vbms"=>33,
"poa_clarification"=>651,
"translation"=>289,
"other"=>3726,
"extension"=>1587,
"foia"=>1828,
"address_verification"=>299,
"hearing_clarification"=>1141}
# Look good!
# Now let's try to match each one up to the correct new type and confirm that they will
# all have a home!
rails c> Task.where(type: ColocatedTask.name).group(:action).keys
# Do each of these exist in our mapping?
rails c> type_for_action = Task.where(type: ColocatedTask.name).group(:action).count.keys.map do |action|
[action, ColocatedTask.find_subclass_by_action(action.to_s).name]
end.to_h
rails c> pp type_for_action
# {"aoj"=>"AojColocatedTask",
"missing_records"=>"MissingRecordsColocatedTask",
"retired_vlj"=>"RetiredVljColocatedTask",
"ihp"=>"IhpColocatedTask",
"unaccredited_rep"=>"UnaccreditedRepColocatedTask",
"arneson"=>"ArnesonColocatedTask",
"new_rep_arguments"=>"NewRepArgumentsColocatedTask",
"missing_hearing_transcripts"=>"MissingHearingTranscriptsColocatedTask",
"schedule_hearing"=>"ScheduleHearingColocatedTask",
"pending_scanning_vbms"=>"PendingScanningVbmsColocatedTask",
"poa_clarification"=>"PoaClarificationColocatedTask",
"translation"=>"TranslationColocatedTask",
"other"=>"OtherColocatedTask",
"extension"=>"ExtensionColocatedTask",
"foia"=>"FoiaColocatedTask",
"address_verification"=>"AddressVerificationColocatedTask",
"hearing_clarification"=>"HearingClarificationColocatedTask"}
# This number should not change:
rails c> ColocatedTask.count
# 16635
# This number should go to zero:
rails c> Task.where(type: ColocatedTask.name).count
# 15444
# These numbers should stay the same as well.
rails c> ColocatedTask.where.not(action: nil).count
# 15444
# These are all the new pups we've created.
rails c> ColocatedTask.where(action: nil).count
# 1193
# Let's make the change!
rails c> counts = type_for_action.keys.map { |action| [action, 0] }.to_h
rails c> Task.where(type: ColocatedTask.name).each do |task|
counts[task.action] += 1
end.map(&:id)
rails c> pp counts
rails c> counts_by_type = type_for_action.values.map { |action| [action, 0] }.to_h
rails c> Task.where(type: ColocatedTask.name).each do |task|
new_type = type_for_action[task.action]
counts_by_type[new_type] += 1
end.map(&:id)
rails c> pp counts_by_type
# {"AojColocatedTask"=>616,
"MissingRecordsColocatedTask"=>373,
"RetiredVljColocatedTask"=>22,
"IhpColocatedTask"=>1070,
"UnaccreditedRepColocatedTask"=>16,
"ArnesonColocatedTask"=>93,
"NewRepArgumentsColocatedTask"=>94,
"MissingHearingTranscriptsColocatedTask"=>397,
"ScheduleHearingColocatedTask"=>3209,
"PendingScanningVbmsColocatedTask"=>33,
"PoaClarificationColocatedTask"=>651,
"TranslationColocatedTask"=>289,
"OtherColocatedTask"=>3726,
"ExtensionColocatedTask"=>1587,
"FoiaColocatedTask"=>1828,
"AddressVerificationColocatedTask"=>299,
"HearingClarificationColocatedTask"=>1141}
# Let's actually make the change now!
rails c> Task.where(type: ColocatedTask.name).each do |task|
new_type = type_for_action[task.action]
task.update!(type: new_type)
end.map(&:id)
# Let's check that this worked out as we expected
# This number should still be 16635 (maybe a few more have been created since we last checked?)
rails c> ColocatedTask.count
# 16649
# Perfect.
# This number should have gone to zero:
rails c> Task.where(type: ColocatedTask.name).count
# 0
# This number should be the same as before.
rails c> ColocatedTask.where.not(action: nil).count
# 15444
# These are all the new pups we've created. Should be 14 larger: 1207
rails c> ColocatedTask.where(action: nil).count
# 1205
# Close enough. Maybe a pair was created between when we got this number and the previous one. Let's check back on this puppy next week to make sure we aren't creating any |
No more pure |
As a midway point to #11113, we created subclasses for each Colocated task action in #11295. The next step in #9057 is to migrate all ColocatedTasks in production to their new subclasses.
This can be done by updating the type of the task.
AC
ColocatedTask
s in production to their respective subclassThe text was updated successfully, but these errors were encountered: