feat: ajout de la gestion des chapitres de manga, incluant la récupération et la sauvegarde des chapitres en français et en anglais, ainsi que l'optimisation de la logique de sauvegarde pour éviter les doublons
This commit is contained in:
parent
34dfa57dc0
commit
0111f1b5f1
@@ -10,6 +10,7 @@ use App\Domain\Shared\Application\Query\ListJobsQuery;
|
||||
use App\Domain\Shared\Application\QueryHandler\ListJobsQueryHandler;
|
||||
use App\Domain\Shared\Domain\Model\JobStatus;
|
||||
use App\Domain\Shared\Infrastructure\ApiPlatform\Resource\GetJobListResource;
|
||||
use ApiPlatform\State\Pagination\ArrayPaginator;
|
||||
|
||||
readonly class GetJobListStateProvider implements ProviderInterface
|
||||
{
|
||||
@@ -17,7 +18,7 @@ readonly class GetJobListStateProvider implements ProviderInterface
|
||||
private ListJobsQueryHandler $handler
|
||||
) {}
|
||||
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): array
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): ArrayPaginator
|
||||
{
|
||||
$filters = $context['filters'] ?? [];
|
||||
|
||||
@@ -60,15 +61,13 @@ readonly class GetJobListStateProvider implements ProviderInterface
|
||||
|
||||
$response = $this->handler->handle($query);
|
||||
|
||||
return [
|
||||
'items' => array_map(
|
||||
return new ArrayPaginator(
|
||||
array_map(
|
||||
fn($job) => GetJobListResource::fromJob($job),
|
||||
$response->items
|
||||
),
|
||||
'total' => $response->total,
|
||||
'page' => $response->page,
|
||||
'limit' => $response->limit,
|
||||
'pages' => $response->pages
|
||||
];
|
||||
0,
|
||||
$response->total
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,10 @@ readonly class DoctrineJobRepository implements JobRepositoryInterface
|
||||
|
||||
public function save(Job $job): void
|
||||
{
|
||||
dump('save', $job);
|
||||
/** @var JobEntity|null $existingJobEntity */
|
||||
$existingJobEntity = $this->entityManager->find(JobEntity::class, $job->id);
|
||||
|
||||
if ($existingJobEntity) {
|
||||
dump('existingJobEntity', $existingJobEntity);
|
||||
$existingJobEntity->setStatus($job->status->value);
|
||||
$existingJobEntity->setStartedAt($job->startedAt);
|
||||
$existingJobEntity->setCompletedAt($job->completedAt);
|
||||
@@ -33,14 +31,11 @@ readonly class DoctrineJobRepository implements JobRepositoryInterface
|
||||
$existingJobEntity->setAttempts($job->attempts);
|
||||
$existingJobEntity->setContext($job->context);
|
||||
$this->entityManager->persist($existingJobEntity);
|
||||
dump('updated', $existingJobEntity);
|
||||
} else {
|
||||
$entity = $this->mapper->toEntity($job);
|
||||
$this->entityManager->persist($entity);
|
||||
dump('created', $entity);
|
||||
}
|
||||
$this->entityManager->flush();
|
||||
dump('flushed');
|
||||
}
|
||||
|
||||
public function get(string $id): Job
|
||||
|
||||
Reference in New Issue
Block a user