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

@@ -14,7 +14,10 @@ readonly class ChapterListItem
public ?int $volume,
public bool $isVisible,
public bool $isAvailable,
public string $createdAt
public string $createdAt,
public bool $isVolumeGroup = false,
public ?string $volumeChaptersRange = null,
public int $volumeChapterCount = 0,
) {
}
}

View File

@@ -54,7 +54,10 @@ readonly class GetMangaChaptersStateProvider implements ProviderInterface
volume: $chapter->volume,
isVisible: $chapter->isVisible,
isAvailable: $chapter->pagesDirectory !== null,
createdAt: $chapter->createdAt
createdAt: $chapter->createdAt,
isVolumeGroup: $chapter->isVolumeGroup,
volumeChaptersRange: $chapter->volumeChaptersRange,
volumeChapterCount: $chapter->volumeChapterCount,
);
}
}

View File

@@ -185,6 +185,21 @@ readonly class LegacyMangaRepository implements MangaRepositoryInterface
);
}
public function findAllChapters(string $mangaId, string $sortOrder = 'desc'): array
{
$queryBuilder = $this->entityManager->createQueryBuilder()
->select('c')
->from(EntityChapter::class, 'c')
->where('c.manga = :mangaId')
->orderBy('c.number', $sortOrder)
->setParameter('mangaId', $mangaId);
return array_map(
fn (EntityChapter $entity) => $this->toChapterDomain($entity),
$queryBuilder->getQuery()->getResult()
);
}
public function countChapters(string $mangaId): int
{
return $this->entityManager->createQueryBuilder()