Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added optimize author validation, handle not found author in job proc… #97

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading