-
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
Stuck Appeals Job now finds appeals where on_hold tasks do not have an active descendant #15595
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ def call | |
appeals_with_zero_tasks, | ||
appeals_with_one_task, | ||
appeals_with_two_tasks_not_distribution, | ||
appeals_with_fully_on_hold_subtree, | ||
dispatched_appeals_on_hold | ||
].flatten.uniq | ||
end | ||
|
@@ -54,6 +55,18 @@ def appeals_with_two_tasks_not_distribution | |
.having("count(tasks) = 2 AND count(case when tasks.type = ? then 1 end) = 0", DistributionTask.name) | ||
end | ||
|
||
# Confirm that all subtrees have an active task | ||
def appeals_with_fully_on_hold_subtree | ||
Appeal.where(id: | ||
Task.left_outer_joins(:children).on_hold | ||
.where.not(type: [RootTask.name, TrackVeteranTask.name, EvidenceSubmissionWindowTask.name, TimedHoldTask.name]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to self: |
||
.group("tasks.id") | ||
.having( | ||
"count(case when children_tasks.status in (?) then 1 end) = 0", | ||
Task.open_statuses | ||
Comment on lines
+63
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Beautifully fast tricksy count logic |
||
).select(:appeal_id).distinct) | ||
end | ||
|
||
def tasks_for(klass_name) | ||
Task.select(:appeal_id).where(appeal_type: klass_name) | ||
end | ||
|
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.
left_outer_joins(:children)
asks rails to grab children tasks.the outer allows us to capture on_hold tasks without any children.
Uses the Rails associations to understand what
children
means.we can't use
includes
as we never invoke the:children
symbol later - its used invisibly to Rails in thehaving
https://blog.saeloun.com/2020/01/08/activerecord-database-performance-n-1-includes-preload-eager-load-pluck.html