fix(workflows): Don't return Workflows while they're being deleted#112541
fix(workflows): Don't return Workflows while they're being deleted#112541
Conversation
| scheduled = CellScheduledDeletion.schedule(rule, days=0, actor=request.user) | ||
| # The Rule's scheduled deletion should take care of the workflow, but | ||
| # we mark it pending immediately so we don't return it while the deletion is in progress. | ||
| for workflow in Workflow.objects.filter(alertruleworkflow__rule_id=rule.id): |
There was a problem hiding this comment.
For another PR; thoughts on us modifying the manager to handle this for us? we are doing that pattern in Detectors here.
There was a problem hiding this comment.
Ah yeah, I'd actually forgotten I was going to do this to the association tables.
I still intend to do that (actually, have a PR going), but in this case, the Workflow is logically deleted, even if you're not going through the association table, so we can't rely on the association table to hide it, we need to mark it pending.
| rule_id=rule_id, workflow__organization=project.organization | ||
| rule_id=rule_id, | ||
| workflow__organization=project.organization, | ||
| workflow__status=ObjectStatus.ACTIVE, |
There was a problem hiding this comment.
any concerns around indexes / query times with filtering by status?
There was a problem hiding this comment.
Not in this case. we're already filtering on workflow attributes here. This does remind me that we could be selecting workflow here and saving a fetch, but that's a separate issue.
Fixes ISWF-2420.