Minor cleanup

This commit is contained in:
Syer10
2023-03-31 19:10:04 -04:00
parent d4599c3331
commit 00370a81fa
6 changed files with 20 additions and 21 deletions

View File

@@ -17,12 +17,12 @@ import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.types.CategoryType
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
import suwayomi.tachidesk.manga.model.table.CategoryTable
import java.util.concurrent.CompletableFuture
import suwayomi.tachidesk.server.JavalinSetup.future
class CategoryDataLoader : KotlinDataLoader<Int, CategoryType> {
override val dataLoaderName = "CategoryDataLoader"
override fun getDataLoader(): DataLoader<Int, CategoryType> = DataLoaderFactory.newDataLoader<Int, CategoryType> { ids ->
CompletableFuture.supplyAsync {
future {
transaction {
addLogger(StdOutSqlLogger)
CategoryTable.select { CategoryTable.id inList ids }
@@ -35,10 +35,11 @@ class CategoryDataLoader : KotlinDataLoader<Int, CategoryType> {
class CategoriesForMangaDataLoader : KotlinDataLoader<Int, List<CategoryType>> {
override val dataLoaderName = "CategoriesForMangaDataLoader"
override fun getDataLoader(): DataLoader<Int, List<CategoryType>> = DataLoaderFactory.newDataLoader<Int, List<CategoryType>> { ids ->
CompletableFuture.supplyAsync {
future {
transaction {
addLogger(StdOutSqlLogger)
val itemsByRef = CategoryMangaTable.innerJoin(CategoryTable).select { CategoryMangaTable.manga inList ids }
val itemsByRef = CategoryMangaTable.innerJoin(CategoryTable)
.select { CategoryMangaTable.manga inList ids }
.map { Pair(it[CategoryMangaTable.manga].value, CategoryType(it)) }
.groupBy { it.first }
.mapValues { it.value.map { pair -> pair.second } }

View File

@@ -16,12 +16,12 @@ import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.types.ChapterType
import suwayomi.tachidesk.manga.model.table.ChapterTable
import java.util.concurrent.CompletableFuture
import suwayomi.tachidesk.server.JavalinSetup.future
class ChapterDataLoader : KotlinDataLoader<Int, ChapterType> {
override val dataLoaderName = "ChapterDataLoader"
override fun getDataLoader(): DataLoader<Int, ChapterType> = DataLoaderFactory.newDataLoader<Int, ChapterType> { ids ->
CompletableFuture.supplyAsync {
future {
transaction {
addLogger(StdOutSqlLogger)
ChapterTable.select { ChapterTable.id inList ids }
@@ -34,7 +34,7 @@ class ChapterDataLoader : KotlinDataLoader<Int, ChapterType> {
class ChaptersForMangaDataLoader : KotlinDataLoader<Int, List<ChapterType>> {
override val dataLoaderName = "ChaptersForMangaDataLoader"
override fun getDataLoader(): DataLoader<Int, List<ChapterType>> = DataLoaderFactory.newDataLoader<Int, List<ChapterType>> { ids ->
CompletableFuture.supplyAsync {
future {
transaction {
addLogger(StdOutSqlLogger)
val chaptersByMangaId = ChapterTable.select { ChapterTable.manga inList ids }

View File

@@ -18,12 +18,12 @@ import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.types.MangaType
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
import suwayomi.tachidesk.manga.model.table.MangaTable
import java.util.concurrent.CompletableFuture
import suwayomi.tachidesk.server.JavalinSetup.future
class MangaDataLoader : KotlinDataLoader<Int, MangaType> {
override val dataLoaderName = "MangaDataLoader"
override fun getDataLoader(): DataLoader<Int, MangaType> = DataLoaderFactory.newDataLoader<Int, MangaType> { ids ->
CompletableFuture.supplyAsync {
future {
transaction {
addLogger(StdOutSqlLogger)
MangaTable.select { MangaTable.id inList ids }
@@ -36,7 +36,7 @@ class MangaDataLoader : KotlinDataLoader<Int, MangaType> {
class MangaForCategoryDataLoader : KotlinDataLoader<Int, List<MangaType>> {
override val dataLoaderName = "MangaForCategoryDataLoader"
override fun getDataLoader(): DataLoader<Int, List<MangaType>> = DataLoaderFactory.newDataLoader<Int, List<MangaType>> { ids ->
CompletableFuture.supplyAsync {
future {
transaction {
addLogger(StdOutSqlLogger)
val itemsByRef = CategoryMangaTable.innerJoin(MangaTable).select { CategoryMangaTable.category inList ids }

View File

@@ -13,12 +13,12 @@ import suwayomi.tachidesk.graphql.types.MangaMetaItem
import suwayomi.tachidesk.graphql.types.MetaType
import suwayomi.tachidesk.manga.model.table.ChapterMetaTable
import suwayomi.tachidesk.manga.model.table.MangaMetaTable
import java.util.concurrent.CompletableFuture
import suwayomi.tachidesk.server.JavalinSetup.future
class ChapterMetaDataLoader : KotlinDataLoader<Int, MetaType> {
override val dataLoaderName = "ChapterMetaDataLoader"
override fun getDataLoader(): DataLoader<Int, MetaType> = DataLoaderFactory.newDataLoader<Int, MetaType> { ids ->
CompletableFuture.supplyAsync {
future {
transaction {
addLogger(StdOutSqlLogger)
val metasByRefId = ChapterMetaTable.select { ChapterMetaTable.ref inList ids }
@@ -33,7 +33,7 @@ class ChapterMetaDataLoader : KotlinDataLoader<Int, MetaType> {
class MangaMetaDataLoader : KotlinDataLoader<Int, MetaType> {
override val dataLoaderName = "MangaMetaDataLoader"
override fun getDataLoader(): DataLoader<Int, MetaType> = DataLoaderFactory.newDataLoader<Int, MetaType> { ids ->
CompletableFuture.supplyAsync {
future {
transaction {
addLogger(StdOutSqlLogger)
val metasByRefId = MangaMetaTable.select { MangaMetaTable.ref inList ids }
@@ -48,7 +48,7 @@ class MangaMetaDataLoader : KotlinDataLoader<Int, MetaType> {
class CategoryMetaDataLoader : KotlinDataLoader<Int, MetaType> {
override val dataLoaderName = "CategoryMetaDataLoader"
override fun getDataLoader(): DataLoader<Int, MetaType> = DataLoaderFactory.newDataLoader<Int, MetaType> { ids ->
CompletableFuture.supplyAsync {
future {
transaction {
addLogger(StdOutSqlLogger)
val metasByRefId = MangaMetaTable.select { MangaMetaTable.ref inList ids }