Report unique custom trigger and action hooks

[MAILPOET-5212]
This commit is contained in:
David Remer
2023-09-25 10:26:34 +03:00
committed by Aschepikov
parent b92d026042
commit 91e2ecded1

View File

@ -303,14 +303,14 @@ class Reporter {
} }
$averageSteps = $activeAutomationCount > 0 ? $totalSteps / $activeAutomationCount : 0; $averageSteps = $activeAutomationCount > 0 ? $totalSteps / $activeAutomationCount : 0;
$customTriggerHooks = array_values(array_map( $customTriggerHooks = array_unique(array_values(array_map(
function(Automation $automation): string { function(Automation $automation): string {
$trigger = $automation->getTrigger('mailpoet:custom-trigger'); $trigger = $automation->getTrigger('mailpoet:custom-trigger');
return $trigger ? (string)$trigger->getArgs()['hook'] : ''; return $trigger ? (string)$trigger->getArgs()['hook'] : '';
}, },
$automationsWithCustomTrigger $automationsWithCustomTrigger
)); )));
$customActionHooks = array_values(array_map( $customActionHooks = array_unique(array_values(array_map(
function(Automation $automation): array { function(Automation $automation): array {
$customActionSteps = array_filter( $customActionSteps = array_filter(
$automation->getSteps(), $automation->getSteps(),
@ -331,7 +331,7 @@ class Reporter {
}, },
$activeAutomations $activeAutomations
)); )));
$customActionHooks = array_values(array_filter(array_merge(...$customActionHooks))); $customActionHooks = array_values(array_filter(array_merge(...$customActionHooks)));
return [ return [
'Automation > Number of active automations' => $activeAutomationCount, 'Automation > Number of active automations' => $activeAutomationCount,