Skip to content

Commit

Permalink
Added optimize author validation, handle not found author in job proc… (
Browse files Browse the repository at this point in the history
#97)

Added optimize author validation
handle not found author in job processor correctly
  • Loading branch information
TomasHermanek authored Dec 2, 2024
1 parent 63228bf commit 1281e1d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ private function processAll(JobAuthorCurrentOptimize $job): void

private function processAuthor(JobAuthorCurrentOptimize $job): void
{
/** @var Author $author */
/** @var Author|null $author */
$author = $this->authorRepository->find($job->getAuthorId());
if (null === $author) {
$this->finishFail($job, 'Author not found');

return;
}

$lastId = $job->getLastBatchProcessedRecord();
$assets = $this->assetRepository->findByAuthor($author, $lastId, $this->bulkSize);
Expand Down
7 changes: 7 additions & 0 deletions src/Entity/JobAuthorCurrentOptimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use AnzuSystems\SerializerBundle\Attributes\Serialize;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

#[ORM\Entity(repositoryClass: JobAuthorCurrentOptimizeRepository::class)]
class JobAuthorCurrentOptimize extends Job
Expand All @@ -19,6 +20,12 @@ class JobAuthorCurrentOptimize extends Job

#[ORM\Column(type: Types::STRING, length: 36, nullable: true)]
#[Serialize]
#[Assert\When(
expression: 'false === this.isProcessAll()',
constraints: [
new Assert\NotNull(),
]
)]
private ?string $authorId = null;

public function isProcessAll(): bool
Expand Down

0 comments on commit 1281e1d

Please sign in to comment.