fix(monitoring): corriger la résolution de l'ID chapitre après synchronisation MangaDex #45
@@ -26,18 +26,26 @@ readonly class RefreshMangaChaptersHandler
|
||||
throw new \RuntimeException('Manga not found');
|
||||
}
|
||||
|
||||
// Synchronisation + récupération des nouveaux IDs
|
||||
$newChapterIds = $this->chapterSynchronizationService->synchronizeChapters($manga);
|
||||
// Synchronisation + récupération des numéros de nouveaux chapitres
|
||||
$newChapterNumbers = $this->chapterSynchronizationService->synchronizeChapters($manga);
|
||||
|
||||
// Mise à jour de la date de monitoring
|
||||
$manga->updateLastMonitoringCheck(new \DateTimeImmutable());
|
||||
$this->mangaRepository->save($manga);
|
||||
|
||||
// Événement de scraping pour chaque nouveau chapitre
|
||||
foreach ($newChapterIds as $chapterId) {
|
||||
$this->eventBus->dispatch(
|
||||
new ChapterReadyForScraping(new ChapterId($chapterId))
|
||||
// On retrouve l'ID réel (PK integer) après save() car le chapitre n'a
|
||||
// son identifiant définitif qu'une fois persisté en base.
|
||||
foreach ($newChapterNumbers as $chapterNumber) {
|
||||
$saved = $this->mangaRepository->findChapterByMangaIdAndNumber(
|
||||
$manga->getId()->getValue(),
|
||||
$chapterNumber
|
||||
);
|
||||
if ($saved) {
|
||||
$this->eventBus->dispatch(
|
||||
new ChapterReadyForScraping(new ChapterId($saved->getId()))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ interface ChapterSynchronizationServiceInterface
|
||||
/**
|
||||
* Synchronise les chapitres d'un manga depuis la source externe.
|
||||
*
|
||||
* @return string[] IDs des nouveaux chapitres ajoutés
|
||||
* @return float[] Numéros des nouveaux chapitres ajoutés
|
||||
*/
|
||||
public function synchronizeChapters(Manga $manga): array;
|
||||
}
|
||||
|
||||
@@ -96,11 +96,11 @@ readonly class MangadxChapterSynchronizationService implements ChapterSynchroniz
|
||||
|
||||
$newChapterIds = [];
|
||||
|
||||
// Sauvegarde uniquement les nouveaux chapitres et collecte leurs IDs
|
||||
// Sauvegarde uniquement les nouveaux chapitres et collecte leurs numéros
|
||||
foreach ($chaptersByNumber as $chapterNumber => $chapter) {
|
||||
if (!isset($existingChapters[(float) $chapterNumber])) {
|
||||
$manga->addChapter($chapter);
|
||||
$newChapterIds[] = $chapter->getId();
|
||||
$newChapterIds[] = $chapter->getNumber();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ class InMemoryChapterSynchronizationService implements ChapterSynchronizationSer
|
||||
'synchronized_at' => new \DateTimeImmutable(),
|
||||
];
|
||||
|
||||
// Retourne les IDs des chapitres synchronisés (simulation)
|
||||
return ['chapter-1', 'chapter-2'];
|
||||
// Retourne les numéros des chapitres synchronisés (simulation)
|
||||
return [1.0, 2.0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user