Skip to content

Commit

Permalink
Handle upload order requests that are stuck in 'processing' state
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Nov 18, 2024
1 parent 69e4f4d commit b62c265
Show file tree
Hide file tree
Showing 18 changed files with 319 additions and 5 deletions.
5 changes: 5 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@
</errorLevel>
</TooManyTemplateParams>
<PluginIssue name="QueryBuilderSetParameter" errorLevel="suppress"/>
<DeprecatedClass>
<errorLevel type="suppress">
<referencedClass name="Sylius\Bundle\AdminBundle\Menu\OrderShowMenuBuilder"/>
</errorLevel>
</DeprecatedClass>
</issueHandlers>
</psalm>
9 changes: 7 additions & 2 deletions src/Command/ProcessUploadOrderRequestsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Setono\SyliusPeakPlugin\Command;

use Setono\SyliusPeakPlugin\Processor\FailedUploadOrderRequestProcessorInterface;
use Setono\SyliusPeakPlugin\Processor\UploadOrderRequestProcessorInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
Expand All @@ -16,13 +17,17 @@
)]
final class ProcessUploadOrderRequestsCommand extends Command
{
public function __construct(private readonly UploadOrderRequestProcessorInterface $uploadOrderRequestProcessor)
{
public function __construct(

Check failure on line 20 in src/Command/ProcessUploadOrderRequestsCommand.php

View workflow job for this annotation

GitHub Actions / Backwards Compatibility Check

The number of required arguments for Setono\SyliusPeakPlugin\Command\ProcessUploadOrderRequestsCommand#__construct() increased from 1 to 2

Check warning on line 20 in src/Command/ProcessUploadOrderRequestsCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Command/ProcessUploadOrderRequestsCommand.php#L20

Added line #L20 was not covered by tests
private readonly UploadOrderRequestProcessorInterface $uploadOrderRequestProcessor,
private readonly FailedUploadOrderRequestProcessorInterface $failedUploadOrderRequestProcessor,
) {
parent::__construct();
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->failedUploadOrderRequestProcessor->process();

Check warning on line 29 in src/Command/ProcessUploadOrderRequestsCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Command/ProcessUploadOrderRequestsCommand.php#L29

Added line #L29 was not covered by tests

$this->uploadOrderRequestProcessor->process();

return 0;
Expand Down
18 changes: 18 additions & 0 deletions src/Event/FailedUploadOrderRequestsQueryBuilderCreatedEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusPeakPlugin\Event;

use Doctrine\ORM\QueryBuilder;

/**
* This event is fired when the query builder for failed upload order requests has been created.
* Listen to this event if you want to filter on associated orders of the upload order requests.
*/
final class FailedUploadOrderRequestsQueryBuilderCreatedEvent
{
public function __construct(public readonly QueryBuilder $queryBuilder)

Check warning on line 15 in src/Event/FailedUploadOrderRequestsQueryBuilderCreatedEvent.php

View check run for this annotation

Codecov / codecov/patch

src/Event/FailedUploadOrderRequestsQueryBuilderCreatedEvent.php#L15

Added line #L15 was not covered by tests
{
}

Check warning on line 17 in src/Event/FailedUploadOrderRequestsQueryBuilderCreatedEvent.php

View check run for this annotation

Codecov / codecov/patch

src/Event/FailedUploadOrderRequestsQueryBuilderCreatedEvent.php#L17

Added line #L17 was not covered by tests
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusPeakPlugin\EventSubscriber\Workflow\UploadOrderRequest;

use Setono\SyliusPeakPlugin\Model\UploadOrderRequestInterface;
use Setono\SyliusPeakPlugin\Workflow\UploadOrderRequestWorkflow;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Workflow\Event\CompletedEvent;
use Webmozart\Assert\Assert;

final class IncrementTriesSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array

Check warning on line 15 in src/EventSubscriber/Workflow/UploadOrderRequest/IncrementTriesSubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/IncrementTriesSubscriber.php#L15

Added line #L15 was not covered by tests
{
return [sprintf('workflow.%s.completed.%s', UploadOrderRequestWorkflow::NAME, UploadOrderRequestWorkflow::TRANSITION_PROCESS) => 'incrementTries'];

Check warning on line 17 in src/EventSubscriber/Workflow/UploadOrderRequest/IncrementTriesSubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/IncrementTriesSubscriber.php#L17

Added line #L17 was not covered by tests
}

public function incrementTries(CompletedEvent $event): void

Check warning on line 20 in src/EventSubscriber/Workflow/UploadOrderRequest/IncrementTriesSubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/IncrementTriesSubscriber.php#L20

Added line #L20 was not covered by tests
{
/** @var UploadOrderRequestInterface|object $uploadOrderRequest */
$uploadOrderRequest = $event->getSubject();
Assert::isInstanceOf($uploadOrderRequest, UploadOrderRequestInterface::class);

Check warning on line 24 in src/EventSubscriber/Workflow/UploadOrderRequest/IncrementTriesSubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/IncrementTriesSubscriber.php#L23-L24

Added lines #L23 - L24 were not covered by tests

$uploadOrderRequest->incrementTries();

Check warning on line 26 in src/EventSubscriber/Workflow/UploadOrderRequest/IncrementTriesSubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/IncrementTriesSubscriber.php#L26

Added line #L26 was not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusPeakPlugin\EventSubscriber\Workflow\UploadOrderRequest;

use Setono\SyliusPeakPlugin\Model\UploadOrderRequestInterface;
use Setono\SyliusPeakPlugin\Workflow\UploadOrderRequestWorkflow;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Workflow\Event\CompletedEvent;
use Webmozart\Assert\Assert;

final class RetrySubscriber implements EventSubscriberInterface
{
public function __construct(private readonly int $maxTries = 5)

Check warning on line 15 in src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php#L15

Added line #L15 was not covered by tests
{
}

Check warning on line 17 in src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php#L17

Added line #L17 was not covered by tests

public static function getSubscribedEvents(): array

Check warning on line 19 in src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php#L19

Added line #L19 was not covered by tests
{
return [sprintf('workflow.%s.completed.%s', UploadOrderRequestWorkflow::NAME, UploadOrderRequestWorkflow::TRANSITION_FAIL) => 'retry'];

Check warning on line 21 in src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php#L21

Added line #L21 was not covered by tests
}

public function retry(CompletedEvent $event): void

Check warning on line 24 in src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php#L24

Added line #L24 was not covered by tests
{
/** @var UploadOrderRequestInterface|object $uploadOrderRequest */
$uploadOrderRequest = $event->getSubject();
Assert::isInstanceOf($uploadOrderRequest, UploadOrderRequestInterface::class);

Check warning on line 28 in src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php#L27-L28

Added lines #L27 - L28 were not covered by tests

if ($uploadOrderRequest->getTries() >= $this->maxTries) {
return;

Check warning on line 31 in src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php#L30-L31

Added lines #L30 - L31 were not covered by tests
}

$event->getWorkflow()->apply($uploadOrderRequest, UploadOrderRequestWorkflow::TRANSITION_RESET);

Check warning on line 34 in src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/RetrySubscriber.php#L34

Added line #L34 was not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusPeakPlugin\EventSubscriber\Workflow\UploadOrderRequest;

use Setono\SyliusPeakPlugin\Model\UploadOrderRequestInterface;
use Setono\SyliusPeakPlugin\Workflow\UploadOrderRequestWorkflow;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Workflow\Event\CompletedEvent;
use Webmozart\Assert\Assert;

final class StateUpdatedSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array

Check warning on line 15 in src/EventSubscriber/Workflow/UploadOrderRequest/StateUpdatedSubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/StateUpdatedSubscriber.php#L15

Added line #L15 was not covered by tests
{
return [sprintf('workflow.%s.completed', UploadOrderRequestWorkflow::NAME) => 'updateTimestamp'];

Check warning on line 17 in src/EventSubscriber/Workflow/UploadOrderRequest/StateUpdatedSubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/StateUpdatedSubscriber.php#L17

Added line #L17 was not covered by tests
}

public function updateTimestamp(CompletedEvent $event): void

Check warning on line 20 in src/EventSubscriber/Workflow/UploadOrderRequest/StateUpdatedSubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/StateUpdatedSubscriber.php#L20

Added line #L20 was not covered by tests
{
/** @var UploadOrderRequestInterface|object $uploadOrderRequest */
$uploadOrderRequest = $event->getSubject();
Assert::isInstanceOf($uploadOrderRequest, UploadOrderRequestInterface::class);

Check warning on line 24 in src/EventSubscriber/Workflow/UploadOrderRequest/StateUpdatedSubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/StateUpdatedSubscriber.php#L23-L24

Added lines #L23 - L24 were not covered by tests

$uploadOrderRequest->setStateUpdatedAt(new \DateTimeImmutable());

Check warning on line 26 in src/EventSubscriber/Workflow/UploadOrderRequest/StateUpdatedSubscriber.php

View check run for this annotation

Codecov / codecov/patch

src/EventSubscriber/Workflow/UploadOrderRequest/StateUpdatedSubscriber.php#L26

Added line #L26 was not covered by tests
}
}
29 changes: 29 additions & 0 deletions src/Model/UploadOrderRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class UploadOrderRequest implements UploadOrderRequestInterface

protected string $state = self::STATE_PENDING;

protected ?\DateTimeInterface $stateUpdatedAt = null;

protected ?OrderInterface $order = null;

protected ?string $request = null;
Expand All @@ -22,6 +24,8 @@ class UploadOrderRequest implements UploadOrderRequestInterface

protected ?int $peakOrderId = null;

protected int $tries = 0;

public function getId(): ?int
{
return $this->id;
Expand All @@ -47,6 +51,16 @@ public function setState(string $state): void
$this->state = $state;
}

public function getStateUpdatedAt(): ?\DateTimeInterface

Check warning on line 54 in src/Model/UploadOrderRequest.php

View check run for this annotation

Codecov / codecov/patch

src/Model/UploadOrderRequest.php#L54

Added line #L54 was not covered by tests
{
return $this->stateUpdatedAt;

Check warning on line 56 in src/Model/UploadOrderRequest.php

View check run for this annotation

Codecov / codecov/patch

src/Model/UploadOrderRequest.php#L56

Added line #L56 was not covered by tests
}

public function setStateUpdatedAt(\DateTimeInterface $stateUpdatedAt): void

Check warning on line 59 in src/Model/UploadOrderRequest.php

View check run for this annotation

Codecov / codecov/patch

src/Model/UploadOrderRequest.php#L59

Added line #L59 was not covered by tests
{
$this->stateUpdatedAt = $stateUpdatedAt;

Check warning on line 61 in src/Model/UploadOrderRequest.php

View check run for this annotation

Codecov / codecov/patch

src/Model/UploadOrderRequest.php#L61

Added line #L61 was not covered by tests
}

public function getOrder(): ?OrderInterface
{
return $this->order;
Expand Down Expand Up @@ -96,4 +110,19 @@ public function setPeakOrderId(?int $peakOrderId): void
{
$this->peakOrderId = $peakOrderId;
}

public function getTries(): int

Check warning on line 114 in src/Model/UploadOrderRequest.php

View check run for this annotation

Codecov / codecov/patch

src/Model/UploadOrderRequest.php#L114

Added line #L114 was not covered by tests
{
return $this->tries;

Check warning on line 116 in src/Model/UploadOrderRequest.php

View check run for this annotation

Codecov / codecov/patch

src/Model/UploadOrderRequest.php#L116

Added line #L116 was not covered by tests
}

public function setTries(int $tries): void

Check warning on line 119 in src/Model/UploadOrderRequest.php

View check run for this annotation

Codecov / codecov/patch

src/Model/UploadOrderRequest.php#L119

Added line #L119 was not covered by tests
{
$this->tries = $tries;

Check warning on line 121 in src/Model/UploadOrderRequest.php

View check run for this annotation

Codecov / codecov/patch

src/Model/UploadOrderRequest.php#L121

Added line #L121 was not covered by tests
}

public function incrementTries(): void

Check warning on line 124 in src/Model/UploadOrderRequest.php

View check run for this annotation

Codecov / codecov/patch

src/Model/UploadOrderRequest.php#L124

Added line #L124 was not covered by tests
{
++$this->tries;

Check warning on line 126 in src/Model/UploadOrderRequest.php

View check run for this annotation

Codecov / codecov/patch

src/Model/UploadOrderRequest.php#L126

Added line #L126 was not covered by tests
}
}
10 changes: 10 additions & 0 deletions src/Model/UploadOrderRequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public function getState(): string;

public function setState(string $state): void;

public function getStateUpdatedAt(): ?\DateTimeInterface;

public function setStateUpdatedAt(\DateTimeInterface $stateUpdatedAt): void;

public function getOrder(): ?OrderInterface;

public function setOrder(?OrderInterface $order): void;
Expand All @@ -45,4 +49,10 @@ public function setError(?string $error): void;
public function getPeakOrderId(): ?int;

public function setPeakOrderId(?int $peakOrderId): void;

public function getTries(): int;

public function setTries(int $tries): void;

public function incrementTries(): void;
}
43 changes: 43 additions & 0 deletions src/Processor/FailedUploadOrderRequestProcessor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusPeakPlugin\Processor;

use Doctrine\ORM\OptimisticLockException;
use Doctrine\Persistence\ManagerRegistry;
use Setono\Doctrine\ORMTrait;
use Setono\SyliusPeakPlugin\Provider\FailedUploadOrderRequestsProviderInterface;
use Setono\SyliusPeakPlugin\Workflow\UploadOrderRequestWorkflow;
use Symfony\Component\Workflow\Exception\LogicException;
use Symfony\Component\Workflow\WorkflowInterface;

final class FailedUploadOrderRequestProcessor implements FailedUploadOrderRequestProcessorInterface
{
use ORMTrait;

public function __construct(

Check warning on line 19 in src/Processor/FailedUploadOrderRequestProcessor.php

View check run for this annotation

Codecov / codecov/patch

src/Processor/FailedUploadOrderRequestProcessor.php#L19

Added line #L19 was not covered by tests
private readonly FailedUploadOrderRequestsProviderInterface $failedUploadOrderRequestsProvider,
private readonly WorkflowInterface $uploadOrderRequestWorkflow,
ManagerRegistry $managerRegistry,
) {
$this->managerRegistry = $managerRegistry;

Check warning on line 24 in src/Processor/FailedUploadOrderRequestProcessor.php

View check run for this annotation

Codecov / codecov/patch

src/Processor/FailedUploadOrderRequestProcessor.php#L24

Added line #L24 was not covered by tests
}

public function process(): void

Check warning on line 27 in src/Processor/FailedUploadOrderRequestProcessor.php

View check run for this annotation

Codecov / codecov/patch

src/Processor/FailedUploadOrderRequestProcessor.php#L27

Added line #L27 was not covered by tests
{
foreach ($this->failedUploadOrderRequestsProvider->getUploadOrderRequests() as $uploadOrderRequest) {

Check warning on line 29 in src/Processor/FailedUploadOrderRequestProcessor.php

View check run for this annotation

Codecov / codecov/patch

src/Processor/FailedUploadOrderRequestProcessor.php#L29

Added line #L29 was not covered by tests
try {
$this->uploadOrderRequestWorkflow->apply($uploadOrderRequest, UploadOrderRequestWorkflow::TRANSITION_FAIL);
} catch (LogicException) {
continue;

Check warning on line 33 in src/Processor/FailedUploadOrderRequestProcessor.php

View check run for this annotation

Codecov / codecov/patch

src/Processor/FailedUploadOrderRequestProcessor.php#L31-L33

Added lines #L31 - L33 were not covered by tests
}

try {
$this->getManager($uploadOrderRequest)->flush();
} catch (OptimisticLockException) {
continue;

Check warning on line 39 in src/Processor/FailedUploadOrderRequestProcessor.php

View check run for this annotation

Codecov / codecov/patch

src/Processor/FailedUploadOrderRequestProcessor.php#L37-L39

Added lines #L37 - L39 were not covered by tests
}
}
}
}
10 changes: 10 additions & 0 deletions src/Processor/FailedUploadOrderRequestProcessorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusPeakPlugin\Processor;

interface FailedUploadOrderRequestProcessorInterface
{
public function process(): void;
}
4 changes: 2 additions & 2 deletions src/Processor/UploadOrderRequestProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class UploadOrderRequestProcessor implements UploadOrderRequestProcessorIn
use ORMTrait;

public function __construct(
private readonly PreQualifiedUploadOrderRequestsProviderInterface $preQualifiedUploadableOrdersProvider,
private readonly PreQualifiedUploadOrderRequestsProviderInterface $preQualifiedUploadOrderRequestsProvider,
private readonly MessageBusInterface $commandBus,
private readonly WorkflowInterface $uploadOrderRequestWorkflow,
ManagerRegistry $managerRegistry,
Expand All @@ -29,7 +29,7 @@ public function __construct(

public function process(): void
{
foreach ($this->preQualifiedUploadableOrdersProvider->getUploadOrderRequests() as $uploadOrderRequest) {
foreach ($this->preQualifiedUploadOrderRequestsProvider->getUploadOrderRequests() as $uploadOrderRequest) {

Check warning on line 32 in src/Processor/UploadOrderRequestProcessor.php

View check run for this annotation

Codecov / codecov/patch

src/Processor/UploadOrderRequestProcessor.php#L32

Added line #L32 was not covered by tests
try {
$this->uploadOrderRequestWorkflow->apply($uploadOrderRequest, UploadOrderRequestWorkflow::TRANSITION_PROCESS);
} catch (LogicException) {
Expand Down
49 changes: 49 additions & 0 deletions src/Provider/FailedUploadOrderRequestsProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusPeakPlugin\Provider;

use Doctrine\Persistence\ManagerRegistry;
use DoctrineBatchUtils\BatchProcessing\SelectBatchIteratorAggregate;
use Psr\EventDispatcher\EventDispatcherInterface;
use Setono\Doctrine\ORMTrait;
use Setono\SyliusPeakPlugin\Event\FailedUploadOrderRequestsQueryBuilderCreatedEvent;
use Setono\SyliusPeakPlugin\Model\UploadOrderRequestInterface;

final class FailedUploadOrderRequestsProvider implements FailedUploadOrderRequestsProviderInterface
{
use ORMTrait;

/**
* @param class-string<UploadOrderRequestInterface> $uploadOrderRequestClass
*/
public function __construct(

Check warning on line 21 in src/Provider/FailedUploadOrderRequestsProvider.php

View check run for this annotation

Codecov / codecov/patch

src/Provider/FailedUploadOrderRequestsProvider.php#L21

Added line #L21 was not covered by tests
ManagerRegistry $managerRegistry,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly string $uploadOrderRequestClass,
private readonly string $processingTimeout = '1 hour',
) {
$this->managerRegistry = $managerRegistry;

Check warning on line 27 in src/Provider/FailedUploadOrderRequestsProvider.php

View check run for this annotation

Codecov / codecov/patch

src/Provider/FailedUploadOrderRequestsProvider.php#L27

Added line #L27 was not covered by tests
}

/**
* @return \Generator<array-key, UploadOrderRequestInterface>
*/
public function getUploadOrderRequests(): \Generator

Check warning on line 33 in src/Provider/FailedUploadOrderRequestsProvider.php

View check run for this annotation

Codecov / codecov/patch

src/Provider/FailedUploadOrderRequestsProvider.php#L33

Added line #L33 was not covered by tests
{
$qb = $this->getRepository($this->uploadOrderRequestClass)->createQueryBuilder('o')
->andWhere('o.state = :orderState')
->andWhere('o.stateUpdatedAt < :stateUpdatedAt')
->setParameter('state', UploadOrderRequestInterface::STATE_PROCESSING)
->setParameter('stateUpdatedAt', new \DateTimeImmutable('-' . $this->processingTimeout))
;

Check warning on line 40 in src/Provider/FailedUploadOrderRequestsProvider.php

View check run for this annotation

Codecov / codecov/patch

src/Provider/FailedUploadOrderRequestsProvider.php#L35-L40

Added lines #L35 - L40 were not covered by tests

$this->eventDispatcher->dispatch(new FailedUploadOrderRequestsQueryBuilderCreatedEvent($qb));

Check warning on line 42 in src/Provider/FailedUploadOrderRequestsProvider.php

View check run for this annotation

Codecov / codecov/patch

src/Provider/FailedUploadOrderRequestsProvider.php#L42

Added line #L42 was not covered by tests

/** @var SelectBatchIteratorAggregate<array-key, UploadOrderRequestInterface> $iterator */
$iterator = SelectBatchIteratorAggregate::fromQuery($qb->getQuery(), 50);

Check warning on line 45 in src/Provider/FailedUploadOrderRequestsProvider.php

View check run for this annotation

Codecov / codecov/patch

src/Provider/FailedUploadOrderRequestsProvider.php#L45

Added line #L45 was not covered by tests

yield from $iterator;

Check warning on line 47 in src/Provider/FailedUploadOrderRequestsProvider.php

View check run for this annotation

Codecov / codecov/patch

src/Provider/FailedUploadOrderRequestsProvider.php#L47

Added line #L47 was not covered by tests
}
}
15 changes: 15 additions & 0 deletions src/Provider/FailedUploadOrderRequestsProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

namespace Setono\SyliusPeakPlugin\Provider;

use Setono\SyliusPeakPlugin\Model\UploadOrderRequestInterface;

interface FailedUploadOrderRequestsProviderInterface
{
/**
* @return iterable<array-key, UploadOrderRequestInterface>
*/
public function getUploadOrderRequests(): iterable;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@
</id>

<field name="version" type="integer" version="true"/>
<field name="state" type="string"/>
<field name="state" column="state" type="string"/>
<field name="stateUpdatedAt" column="state_updated_at" type="datetime" nullable="true"/>
<field name="request" type="text" nullable="true"/>
<field name="response" type="text" nullable="true"/>
<field name="error" type="text" nullable="true"/>
<field name="peakOrderId" type="integer" nullable="true"/>
<field name="tries" type="integer"/>

<one-to-one field="order" target-entity="Sylius\Component\Order\Model\OrderInterface" inversed-by="peakUploadOrderRequest">
<join-column name="order_id" referenced-column-name="id" nullable="false" unique="true" on-delete="CASCADE"/>
</one-to-one>

<indexes>
<index columns="state,state_updated_at"/>
</indexes>
</mapped-superclass>
</doctrine-mapping>
1 change: 1 addition & 0 deletions src/Resources/config/services/command.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<service id="Setono\SyliusPeakPlugin\Command\ProcessUploadOrderRequestsCommand">
<argument type="service" id="Setono\SyliusPeakPlugin\Processor\UploadOrderRequestProcessorInterface"/>
<argument type="service" id="Setono\SyliusPeakPlugin\Processor\FailedUploadOrderRequestProcessorInterface"/>

<tag name="console.command"/>
</service>
Expand Down
Loading

0 comments on commit b62c265

Please sign in to comment.