-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3423 from DFE-Digital/CAPT-1964/reset-slc-plans
Remove falsely passed task
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
db/data/20241121115931_remove_student_loan_plan_task_from_claims_with_no_slc_plan.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Run me with `rails runner db/data/20241121115931_remove_student_loan_plan_task_from_claims_with_no_slc_plan.rb` | ||
|
||
# Put your Ruby code here | ||
claim_ids = Claim | ||
.select(:id) | ||
.joins(:notes) | ||
.joins(:tasks) | ||
.where(student_loan_plan: nil) | ||
.where("notes.body ilike ?", "%[SLC Student loan plan] - Matched%") | ||
.where(tasks: {name: "student_loan_plan", passed: true}) | ||
|
||
tasks_to_destroy = Task.where( | ||
claim_id: claim_ids, | ||
name: "student_loan_plan", | ||
passed: true | ||
) | ||
|
||
if tasks_to_destroy.count == 704 | ||
tasks_to_destroy.destroy_all | ||
else | ||
puts "Expected to find 704 tasks, but found #{tasks_to_destroy.count}" | ||
end |