Fix ordering of next_step
We are actually waiting for the next_step to be executed and therefore we do not need to map the step to the previous one. [MAILPOET-5091]
This commit is contained in:
@ -5,7 +5,6 @@ namespace MailPoet\Automation\Integrations\MailPoet\Analytics\Controller;
|
||||
use MailPoet\Automation\Engine\Data\Automation;
|
||||
use MailPoet\Automation\Engine\Data\AutomationRun;
|
||||
use MailPoet\Automation\Engine\Data\AutomationRunLog;
|
||||
use MailPoet\Automation\Engine\Data\NextStep;
|
||||
use MailPoet\Automation\Engine\Data\Step;
|
||||
use MailPoet\Automation\Engine\Storage\AutomationRunLogStorage;
|
||||
use MailPoet\Automation\Engine\Storage\AutomationRunStorage;
|
||||
@ -34,23 +33,13 @@ class StepStatisticController {
|
||||
$query->getAfter(),
|
||||
$query->getBefore()
|
||||
);
|
||||
$stepData = [];
|
||||
foreach ($rawData as $rawDatum) {
|
||||
$stepData[$rawDatum['next_step_id']] = (int)$rawDatum['count'];
|
||||
}
|
||||
$stepsWithValues = array_keys($stepData);
|
||||
|
||||
$data = [];
|
||||
foreach ($automation->getSteps() as $step) {
|
||||
$nextStepIds = array_map(function(NextStep $step) { return $step->getId();
|
||||
|
||||
}, $step->getNextSteps());
|
||||
$matchedSteps = array_intersect($nextStepIds, $stepsWithValues);
|
||||
foreach ($matchedSteps as $matchedStep) {
|
||||
if (!isset($data[$step->getId()])) {
|
||||
$data[$step->getId()] = 0;
|
||||
foreach ($rawData as $rawDatum) {
|
||||
if ($rawDatum['next_step_id'] === $step->getId()) {
|
||||
$data[$step->getId()] = (int)$rawDatum['count'];
|
||||
}
|
||||
$data[$step->getId()] += $stepData[$matchedStep];
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
|
Reference in New Issue
Block a user