return (int)$subjectData['automation_run_id'] === (int)$runData['id'];
}
));
return AutomationRun::fromArray($runData);
},
$automationRuns
);
}
/**
* @param Automation $automation
* @return int
*/
public function getCountByAutomationAndSubject(Automation $automation, Subject $subject): int {
$table = esc_sql($this->table);
$subjectTable = esc_sql($this->subjectTable);
/** @var literal-string $sql */
$sql = "SELECT count(DISTINCT runs.id) as count from $table as runs
JOIN $subjectTable as subjects on runs.id = subjects.automation_run_id
WHERE runs.automation_id = %d
AND subjects.hash = %s";
$result = $this->wpdb->get_col(
(string)$this->wpdb->prepare($sql, $automation->getId(), $subject->getHash())
);
return $result ? (int)current($result) : 0;
}
public function getCountForAutomation(Automation $automation, string ...$status): int {
$table = esc_sql($this->table);
if (!count($status)) {
/** @var literal-string $sql */
$sql = "
SELECT COUNT(id) as count
FROM $table
WHERE automation_id = %d
";
$query = (string)$this->wpdb->prepare($sql, $automation->getId());
$result = $this->wpdb->get_col($query);
return $result ? (int)current($result) : 0;
}
$statusSql = (string)$this->wpdb->prepare(implode(',', array_fill(0, count($status), '%s')), ...$status);
/** @var literal-string $sql */
$sql = "
SELECT COUNT(id) as count
FROM $table
WHERE automation_id = %d
AND status IN ($statusSql)
";
$query = (string)$this->wpdb->prepare($sql, $automation->getId());
$result = $this->wpdb->get_col($query);
return $result ? (int)current($result) : 0;
}
public function updateStatus(int $id, string $status): void {
$table = esc_sql($this->table);
/** @var literal-string $sql */
$sql = "
UPDATE $table
SET status = %s, updated_at = current_timestamp()
WHERE id = %d
";
$query = (string)$this->wpdb->prepare($sql, $status, $id);
$result = $this->wpdb->query($query);
if ($result === false) {
throw Exceptions::databaseError($this->wpdb->last_error);
}
}
public function updateNextStep(int $id, ?string $nextStepId): void {
$table = esc_sql($this->table);
/** @var literal-string $sql */
$sql = "
UPDATE $table
SET next_step_id = %s, updated_at = current_timestamp()
WHERE id = %d
";
$query = (string)$this->wpdb->prepare($sql, $nextStepId, $id);
$result = $this->wpdb->query($query);
if ($result === false) {
throw Exceptions::databaseError($this->wpdb->last_error);
}
}
public function getAutomationStepStatisticForTimeFrame(int $automationId, string $status, \DateTimeImmutable $after, \DateTimeImmutable $before, int $versionId = null): array {
$table = esc_sql($this->table);
$where = "automation_id = %d
AND `status` = %s
AND created_at BETWEEN %s AND %s";
if ($versionId) {
$where .= " AND version_id = %d";
}
/** @var literal-string $sql */
$sql = "
SELECT
COUNT(id) AS `count`,
next_step_id
FROM $table as log
WHERE $where
GROUP BY next_step_id
";
$sql = $versionId ?
$this->wpdb->prepare($sql, $automationId, $status, $after->format('Y-m-d H:i:s'), $before->format('Y-m-d H:i:s'), $versionId) :
$this->wpdb->prepare($sql, $automationId, $status, $after->format('Y-m-d H:i:s'), $before->format('Y-m-d H:i:s'));
$sql = is_string($sql) ? $sql : '';
$result = $this->wpdb->get_results($sql, ARRAY_A);
return is_array($result) ? $result : [];
}
public function truncate(): void {
$table = esc_sql($this->table);
$this->wpdb->query("TRUNCATE $table");
$table = esc_sql($this->subjectTable);
$this->wpdb->query("TRUNCATE $table");
}
}
Fatal error: Uncaught Error: Class "MailPoet\Automation\Engine\Storage\AutomationRunStorage" not found in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php:1531
Stack trace:
#0 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(1675): MailPoetGenerated\FreeCachedContainer->getStepHandlerService()
#1 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2640): MailPoetGenerated\FreeCachedContainer->getEngineService()
#2 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(122): MailPoetGenerated\FreeCachedContainer->getInitializerService()
#3 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(110): MailPoetVendor\Symfony\Component\DependencyInjection\Container->make('MailPoet\\Config...', 1)
#4 /htdocs/wp-content/plugins/mailpoet/lib/DI/ContainerWrapper.php(39): MailPoetVendor\Symfony\Component\DependencyInjection\Container->get('MailPoet\\Config...')
#5 /htdocs/wp-content/plugins/mailpoet/mailpoet_initializer.php(89): MailPoet\DI\ContainerWrapper->get('MailPoet\\Config...')
#6 /htdocs/wp-content/plugins/mailpoet/mailpoet.php(194): require_once('/htdocs/wp-cont...')
#7 /htdocs/wp-settings.php(545): include_once('/htdocs/wp-cont...')
#8 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...')
#9 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...')
#10 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...')
#11 /htdocs/index.php(17): require('/htdocs/wp-blog...')
#12 {main}
thrown in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php on line 1531