Use new getCountForWorkflow for performance

[MAILPOET-4731]
This commit is contained in:
David Remer
2022-10-25 08:57:28 +03:00
committed by Jan Jakeš
parent 9773408c8b
commit c10f80457d

View File

@@ -228,15 +228,10 @@ class StepHandler {
private function postProcessWorkflow(Workflow $workflow): void {
if ($workflow->getStatus() === Workflow::STATUS_DEACTIVATING) {
$activeRuns = array_filter(
$this->workflowRunStorage->getWorkflowRunsForWorkflow($workflow),
function(WorkflowRun $run): bool {
return $run->getStatus() === WorkflowRun::STATUS_RUNNING;
}
);
$activeRuns = $this->workflowRunStorage->getCountForWorkflow($workflow, WorkflowRun::STATUS_RUNNING);
// Set a deactivating Workflow to inactive once all workflow runs are finished.
if (!$activeRuns) {
if ($activeRuns === 0) {
$workflow->setStatus(Workflow::STATUS_INACTIVE);
$this->workflowStorage->updateWorkflow($workflow);
}