-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(workflows): Don't return Workflows while they're being deleted #112541
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
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 |
|---|---|---|
|
|
@@ -451,6 +451,10 @@ def delete(self, request: Request, project: Project, rule: Rule | Workflow) -> R | |
| rule=rule, user_id=request.user.id, type=RuleActivityType.DELETED.value | ||
| ) | ||
| 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): | ||
|
Contributor
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. For another PR; thoughts on us modifying the manager to handle this for us? we are doing that pattern in
Member
Author
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. Ah yeah, I'd actually forgotten I was going to do this to the association tables. |
||
| workflow.update(status=ObjectStatus.PENDING_DELETION) | ||
|
|
||
| self.create_audit_entry( | ||
| request=request, | ||
|
|
||
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.
any concerns around indexes / query times with filtering by status?
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.
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.