Add version_id to WorkflowRun
[MAILPOET-4430]
This commit is contained in:
@ -59,7 +59,7 @@ class TriggerHandler {
|
|||||||
$loadedSubjects[] = $this->subjectLoader->loadSubject($subject['key'], $subject['args']);
|
$loadedSubjects[] = $this->subjectLoader->loadSubject($subject['key'], $subject['args']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$workflowRun = new WorkflowRun($workflow->getId(), $trigger->getKey(), $loadedSubjects);
|
$workflowRun = new WorkflowRun($workflow->getId(), $workflow->getVersionId(), $trigger->getKey(), $loadedSubjects);
|
||||||
$workflowRunId = $this->workflowRunStorage->createWorkflowRun($workflowRun);
|
$workflowRunId = $this->workflowRunStorage->createWorkflowRun($workflowRun);
|
||||||
|
|
||||||
$this->actionScheduler->enqueue(Hooks::WORKFLOW_STEP, [
|
$this->actionScheduler->enqueue(Hooks::WORKFLOW_STEP, [
|
||||||
|
@ -20,6 +20,9 @@ class WorkflowRun {
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
private $workflowId;
|
private $workflowId;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
private $versionId;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $triggerKey;
|
private $triggerKey;
|
||||||
|
|
||||||
@ -43,11 +46,13 @@ class WorkflowRun {
|
|||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
int $workflowId,
|
int $workflowId,
|
||||||
|
int $versionId,
|
||||||
string $triggerKey,
|
string $triggerKey,
|
||||||
array $subjects,
|
array $subjects,
|
||||||
int $id = null
|
int $id = null
|
||||||
) {
|
) {
|
||||||
$this->workflowId = $workflowId;
|
$this->workflowId = $workflowId;
|
||||||
|
$this->versionId = $versionId;
|
||||||
$this->triggerKey = $triggerKey;
|
$this->triggerKey = $triggerKey;
|
||||||
$this->subjects = $subjects;
|
$this->subjects = $subjects;
|
||||||
|
|
||||||
@ -72,6 +77,10 @@ class WorkflowRun {
|
|||||||
return $this->workflowId;
|
return $this->workflowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getVersionId(): int {
|
||||||
|
return $this->workflowId;
|
||||||
|
}
|
||||||
|
|
||||||
public function getTriggerKey(): string {
|
public function getTriggerKey(): string {
|
||||||
return $this->triggerKey;
|
return $this->triggerKey;
|
||||||
}
|
}
|
||||||
@ -130,6 +139,7 @@ class WorkflowRun {
|
|||||||
public function toArray(): array {
|
public function toArray(): array {
|
||||||
return [
|
return [
|
||||||
'workflow_id' => $this->workflowId,
|
'workflow_id' => $this->workflowId,
|
||||||
|
'version_id' => $this->versionId,
|
||||||
'trigger_key' => $this->triggerKey,
|
'trigger_key' => $this->triggerKey,
|
||||||
'status' => $this->status,
|
'status' => $this->status,
|
||||||
'created_at' => $this->createdAt->format(DateTimeImmutable::W3C),
|
'created_at' => $this->createdAt->format(DateTimeImmutable::W3C),
|
||||||
@ -143,7 +153,7 @@ class WorkflowRun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function fromArray(array $data): self {
|
public static function fromArray(array $data): self {
|
||||||
$workflowRun = new WorkflowRun((int)$data['workflow_id'], $data['trigger_key'], $data['subjects']);
|
$workflowRun = new WorkflowRun((int)$data['workflow_id'], (int)$data['version_id'], $data['trigger_key'], $data['subjects']);
|
||||||
$workflowRun->id = (int)$data['id'];
|
$workflowRun->id = (int)$data['id'];
|
||||||
$workflowRun->status = $data['status'];
|
$workflowRun->status = $data['status'];
|
||||||
$workflowRun->createdAt = $data['created_at'];
|
$workflowRun->createdAt = $data['created_at'];
|
||||||
|
@ -47,6 +47,7 @@ class Migrator {
|
|||||||
CREATE TABLE {$this->prefix}workflow_runs (
|
CREATE TABLE {$this->prefix}workflow_runs (
|
||||||
id int(11) unsigned NOT NULL AUTO_INCREMENT,
|
id int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
workflow_id int(11) unsigned NOT NULL,
|
workflow_id int(11) unsigned NOT NULL,
|
||||||
|
version_id int(11) unsigned NOT NULL,
|
||||||
trigger_key varchar(255) NOT NULL,
|
trigger_key varchar(255) NOT NULL,
|
||||||
status varchar(255) NOT NULL,
|
status varchar(255) NOT NULL,
|
||||||
created_at timestamp NOT NULL,
|
created_at timestamp NOT NULL,
|
||||||
|
@ -99,7 +99,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
|||||||
|
|
||||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||||
$workflow = new Workflow('some-workflow', [$step]);
|
$workflow = new Workflow('some-workflow', [$step]);
|
||||||
$run = new WorkflowRun(1, 'trigger-key', $subjects);
|
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||||
|
|
||||||
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
||||||
expect($scheduled)->count(0);
|
expect($scheduled)->count(0);
|
||||||
@ -121,7 +121,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
|||||||
|
|
||||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||||
$workflow = new Workflow('some-workflow', [$step]);
|
$workflow = new Workflow('some-workflow', [$step]);
|
||||||
$run = new WorkflowRun(1, 'trigger-key', $subjects);
|
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||||
|
|
||||||
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
||||||
expect($scheduled)->count(0);
|
expect($scheduled)->count(0);
|
||||||
@ -153,7 +153,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
|||||||
|
|
||||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||||
$workflow = new Workflow('some-workflow', [$step]);
|
$workflow = new Workflow('some-workflow', [$step]);
|
||||||
$run = new WorkflowRun(1, 'trigger-key', $subjects);
|
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||||
|
|
||||||
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
||||||
expect($scheduled)->count(0);
|
expect($scheduled)->count(0);
|
||||||
@ -182,7 +182,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
|||||||
|
|
||||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||||
$workflow = new Workflow('some-workflow', [$step]);
|
$workflow = new Workflow('some-workflow', [$step]);
|
||||||
$run = new WorkflowRun(1, 'trigger-key', $subjects);
|
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||||
|
|
||||||
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
||||||
expect($scheduled)->count(0);
|
expect($scheduled)->count(0);
|
||||||
@ -220,7 +220,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
|||||||
|
|
||||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||||
$workflow = new Workflow('some-workflow', [$step]);
|
$workflow = new Workflow('some-workflow', [$step]);
|
||||||
$run = new WorkflowRun(1, 'trigger-key', $subjects);
|
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||||
|
|
||||||
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
||||||
expect($scheduled)->count(0);
|
expect($scheduled)->count(0);
|
||||||
@ -249,7 +249,7 @@ class SendEmailActionTest extends \MailPoetTest {
|
|||||||
|
|
||||||
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
$step = new Step('step-id', Step::TYPE_ACTION, 'step-key', null, ['email_id' => $email->getId()]);
|
||||||
$workflow = new Workflow('some-workflow', [$step]);
|
$workflow = new Workflow('some-workflow', [$step]);
|
||||||
$run = new WorkflowRun(1, 'trigger-key', $subjects);
|
$run = new WorkflowRun(1, 1, 'trigger-key', $subjects);
|
||||||
|
|
||||||
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
$scheduled = $this->scheduledTasksRepository->findByNewsletterAndSubscriberId($email, (int)$subscriber->getId());
|
||||||
expect($scheduled)->count(0);
|
expect($scheduled)->count(0);
|
||||||
|
Reference in New Issue
Block a user