feat: ajout de la gestion des jobs avec création, récupération et filtrage via l'API, incluant des entités et des mappers pour les échecs et les jobs

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-03-29 15:15:14 +01:00
parent d7088b14c2
commit d7ccc1e603
33 changed files with 1113 additions and 595 deletions

View File

@@ -15,7 +15,23 @@ use Symfony\Component\Validator\Constraints as Assert;
processor: CreateMangaProcessor::class,
openapiContext: [
'summary' => 'Create a new manga from Mangadex',
'description' => 'Creates a new manga by fetching its data from Mangadex using an external ID'
'description' => 'Creates a new manga by fetching its data from Mangadex using an external ID',
'requestBody' => [
'content' => [
'application/json' => [
'schema' => [
'type' => 'object',
'required' => ['externalId'],
'properties' => [
'externalId' => [
'type' => 'string',
'description' => 'The Mangadex ID of the manga'
]
]
]
]
]
]
]
)
]
@@ -24,4 +40,4 @@ class CreateMangaResource
{
#[Assert\NotBlank]
public string $externalId;
}
}

View File

@@ -34,10 +34,11 @@ readonly class SearchMangaStateProvider implements ProviderInterface
genres: $item->genres,
status: $item->status,
imageUrl: $item->imageUrl,
thumbnailUrl: $item->thumbnailUrl,
rating: $item->rating
),
$response->items
)
);
}
}
}

View File

@@ -59,7 +59,7 @@ readonly class MangadexProvider implements MangaProviderInterface
try {
$attributes = $result['attributes'];
$title = $attributes['title']['en'] ?? null;
if (!$title) {
return null;
}
@@ -85,17 +85,19 @@ readonly class MangadexProvider implements MangaProviderInterface
}
return new Manga(
new MangaId((string) Uuid::uuid4()),
new MangaTitle($title),
new MangaSlug($this->slugger->slug($title)->lower()),
$attributes['description']['fr'] ?? $attributes['description']['en'] ?? '',
$author,
$attributes['year'] ?? 0,
$genres,
$attributes['status'],
new ExternalId($result['id']),
$imageUrl,
null
id: new MangaId((string) Uuid::uuid4()),
title: new MangaTitle($title),
slug: new MangaSlug($this->slugger->slug($title)->lower()),
description: $attributes['description']['fr'] ?? $attributes['description']['en'] ?? '',
author: $author,
publicationYear: $attributes['year'] ?? 0,
genres: $genres,
status: $attributes['status'],
externalId: new ExternalId($result['id']),
imageUrl: $imageUrl,
rating: null,
imageUrls: null,
createdAt: new \DateTimeImmutable(),
);
} catch (\Exception $e) {
return null;
@@ -128,13 +130,13 @@ readonly class MangadexProvider implements MangaProviderInterface
{
try {
$result = $this->client->getManga($externalId->getValue());
if (!isset($result['data'])) {
return null;
}
$manga = $this->createMangaFromResult($result['data']);
if ($manga) {
$this->enrichWithRatings([$manga]);
}
@@ -144,4 +146,4 @@ readonly class MangadexProvider implements MangaProviderInterface
return null;
}
}
}
}