feat(manga): regrouper les chapitres d'un volume importé dans la liste API

Les chapitres partageant le même pagesDirectory non-null et le même volume
non-null (import CBZ en bloc) sont fusionnés en un seul item isVolumeGroup=true
côté Application, avec volumeChaptersRange et volumeChapterCount. Le frontend
affiche "Vol. X — Chapitres Y-Z" à la place de N lignes identiques.
This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2026-03-15 19:21:02 +01:00
parent c268b2c312
commit fb8f64ee59
9 changed files with 287 additions and 19 deletions

View File

@@ -112,6 +112,23 @@ class InMemoryMangaRepository implements MangaRepositoryInterface
};
}
public function findAllChapters(string $mangaId, string $sortOrder = 'desc'): array
{
if (!isset($this->chapters[$mangaId])) {
return [];
}
$chapters = $this->chapters[$mangaId];
usort($chapters, function (Chapter $a, Chapter $b) use ($sortOrder) {
return $sortOrder === 'desc'
? $b->getNumber() <=> $a->getNumber()
: $a->getNumber() <=> $b->getNumber();
});
return $chapters;
}
public function findChapters(string $mangaId, int $page = 1, int $limit = 20, string $sortOrder = 'desc'): array
{
if (!isset($this->chapters[$mangaId])) {
@@ -198,6 +215,15 @@ class InMemoryMangaRepository implements MangaRepositoryInterface
));
}
public function addChapter(string $mangaId, Chapter $chapter): void
{
if (!isset($this->chapters[$mangaId])) {
$this->chapters[$mangaId] = [];
}
$this->chapters[$mangaId][] = $chapter;
$this->chaptersById[$chapter->getId()] = $chapter;
}
public function addChaptersToManga(string $mangaId, int $count): void
{
$this->chapters[$mangaId] = [];