From 5372ef8f0c4c6250d6a08bccc1b913c67cddeab5 Mon Sep 17 00:00:00 2001 From: Mitchell Syer Date: Sun, 2 Jul 2023 11:46:04 -0400 Subject: [PATCH] Manga for Source data loader (#588) --- .../graphql/dataLoaders/MangaDataLoader.kt | 15 +++++++++++++++ .../server/TachideskDataLoaderRegistryFactory.kt | 2 ++ 2 files changed, 17 insertions(+) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/MangaDataLoader.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/MangaDataLoader.kt index 71e1f9ddc..491291806 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/MangaDataLoader.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/MangaDataLoader.kt @@ -65,3 +65,18 @@ class MangaForCategoryDataLoader : KotlinDataLoader { } } } + +class MangaForSourceDataLoader : KotlinDataLoader { + override val dataLoaderName = "MangaForSourceDataLoader" + override fun getDataLoader(): DataLoader = DataLoaderFactory.newDataLoader { ids -> + future { + transaction { + addLogger(Slf4jSqlDebugLogger) + val mangaBySourceId = MangaTable.select { MangaTable.sourceReference inList ids } + .map { MangaType(it) } + .groupBy { it.sourceId } + ids.map { (mangaBySourceId[it] ?: emptyList()).toNodeList() } + } + } + } +} diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TachideskDataLoaderRegistryFactory.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TachideskDataLoaderRegistryFactory.kt index 3621edf2b..2a8ac68d3 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TachideskDataLoaderRegistryFactory.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TachideskDataLoaderRegistryFactory.kt @@ -19,6 +19,7 @@ import suwayomi.tachidesk.graphql.dataLoaders.ExtensionForSourceDataLoader import suwayomi.tachidesk.graphql.dataLoaders.GlobalMetaDataLoader import suwayomi.tachidesk.graphql.dataLoaders.MangaDataLoader import suwayomi.tachidesk.graphql.dataLoaders.MangaForCategoryDataLoader +import suwayomi.tachidesk.graphql.dataLoaders.MangaForSourceDataLoader import suwayomi.tachidesk.graphql.dataLoaders.MangaMetaDataLoader import suwayomi.tachidesk.graphql.dataLoaders.SourceDataLoader import suwayomi.tachidesk.graphql.dataLoaders.SourcesForExtensionDataLoader @@ -34,6 +35,7 @@ class TachideskDataLoaderRegistryFactory { ChapterMetaDataLoader(), MangaMetaDataLoader(), MangaForCategoryDataLoader(), + MangaForSourceDataLoader(), CategoryDataLoader(), CategoryMetaDataLoader(), CategoriesForMangaDataLoader(),