Feature/update to exposed v0.57.0 (#1150)

* Update to exposed-migrations v3.5.0

* Update to kotlin-logging v7.0.0

* Update to exposed v0.46.0

* Update to exposed v0.47.0

* Update to exposed v0.55.0

* Update to exposed v0.56.0

* Update to exposed v0.57.0
This commit is contained in:
schroda
2024-12-08 05:49:11 +01:00
committed by GitHub
parent f926714544
commit 1d541a30ae
87 changed files with 463 additions and 359 deletions

View File

@@ -13,7 +13,7 @@ import org.dataloader.DataLoader
import org.dataloader.DataLoaderFactory
import org.jetbrains.exposed.sql.Slf4jSqlDebugLogger
import org.jetbrains.exposed.sql.addLogger
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.types.CategoryNodeList
import suwayomi.tachidesk.graphql.types.CategoryNodeList.Companion.toNodeList
@@ -32,7 +32,8 @@ class CategoryDataLoader : KotlinDataLoader<Int, CategoryType> {
addLogger(Slf4jSqlDebugLogger)
val categories =
CategoryTable
.select { CategoryTable.id inList ids }
.selectAll()
.where { CategoryTable.id inList ids }
.map { CategoryType(it) }
.associateBy { it.id }
ids.map { categories[it] }
@@ -50,7 +51,7 @@ class CategoryForIdsDataLoader : KotlinDataLoader<List<Int>, CategoryNodeList> {
transaction {
addLogger(Slf4jSqlDebugLogger)
val ids = categoryIds.flatten().distinct()
val categories = CategoryTable.select { CategoryTable.id inList ids }.map { CategoryType(it) }
val categories = CategoryTable.selectAll().where { CategoryTable.id inList ids }.map { CategoryType(it) }
categoryIds.map { categoryIds ->
categories.filter { it.id in categoryIds }.toNodeList()
}
@@ -70,7 +71,8 @@ class CategoriesForMangaDataLoader : KotlinDataLoader<Int, CategoryNodeList> {
val itemsByRef =
CategoryMangaTable
.innerJoin(CategoryTable)
.select { CategoryMangaTable.manga inList ids }
.selectAll()
.where { 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,7 +16,7 @@ import org.jetbrains.exposed.sql.SortOrder
import org.jetbrains.exposed.sql.addLogger
import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.count
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.types.ChapterNodeList
import suwayomi.tachidesk.graphql.types.ChapterNodeList.Companion.toNodeList
@@ -34,7 +34,8 @@ class ChapterDataLoader : KotlinDataLoader<Int, ChapterType?> {
addLogger(Slf4jSqlDebugLogger)
val chapters =
ChapterTable
.select { ChapterTable.id inList ids }
.selectAll()
.where { ChapterTable.id inList ids }
.map { ChapterType(it) }
.associateBy { it.id }
ids.map { chapters[it] }
@@ -53,7 +54,8 @@ class ChaptersForMangaDataLoader : KotlinDataLoader<Int, ChapterNodeList> {
addLogger(Slf4jSqlDebugLogger)
val chaptersByMangaId =
ChapterTable
.select { ChapterTable.manga inList ids }
.selectAll()
.where { ChapterTable.manga inList ids }
.map { ChapterType(it) }
.groupBy { it.mangaId }
ids.map { (chaptersByMangaId[it] ?: emptyList()).toNodeList() }
@@ -72,9 +74,11 @@ class DownloadedChapterCountForMangaDataLoader : KotlinDataLoader<Int, Int> {
addLogger(Slf4jSqlDebugLogger)
val downloadedChapterCountByMangaId =
ChapterTable
.slice(ChapterTable.manga, ChapterTable.isDownloaded.count())
.select { (ChapterTable.manga inList ids) and (ChapterTable.isDownloaded eq true) }
.groupBy(ChapterTable.manga)
.select(ChapterTable.manga, ChapterTable.isDownloaded.count())
.where {
(ChapterTable.manga inList ids) and
(ChapterTable.isDownloaded eq true)
}.groupBy(ChapterTable.manga)
.associate { it[ChapterTable.manga].value to it[ChapterTable.isDownloaded.count()] }
ids.map { downloadedChapterCountByMangaId[it]?.toInt() ?: 0 }
}
@@ -92,9 +96,11 @@ class UnreadChapterCountForMangaDataLoader : KotlinDataLoader<Int, Int> {
addLogger(Slf4jSqlDebugLogger)
val unreadChapterCountByMangaId =
ChapterTable
.slice(ChapterTable.manga, ChapterTable.isRead.count())
.select { (ChapterTable.manga inList ids) and (ChapterTable.isRead eq false) }
.groupBy(ChapterTable.manga)
.select(ChapterTable.manga, ChapterTable.isRead.count())
.where {
(ChapterTable.manga inList ids) and
(ChapterTable.isRead eq false)
}.groupBy(ChapterTable.manga)
.associate { it[ChapterTable.manga].value to it[ChapterTable.isRead.count()] }
ids.map { unreadChapterCountByMangaId[it]?.toInt() ?: 0 }
}
@@ -112,9 +118,11 @@ class BookmarkedChapterCountForMangaDataLoader : KotlinDataLoader<Int, Int> {
addLogger(Slf4jSqlDebugLogger)
val bookmarkedChapterCountByMangaId =
ChapterTable
.slice(ChapterTable.manga, ChapterTable.isBookmarked.count())
.select { (ChapterTable.manga inList ids) and (ChapterTable.isBookmarked eq true) }
.groupBy(ChapterTable.manga)
.select(ChapterTable.manga, ChapterTable.isBookmarked.count())
.where {
(ChapterTable.manga inList ids) and
(ChapterTable.isBookmarked eq true)
}.groupBy(ChapterTable.manga)
.associate { it[ChapterTable.manga].value to it[ChapterTable.isBookmarked.count()] }
ids.map { bookmarkedChapterCountByMangaId[it]?.toInt() ?: 0 }
}
@@ -132,9 +140,14 @@ class HasDuplicateChaptersForMangaDataLoader : KotlinDataLoader<Int, Boolean> {
addLogger(Slf4jSqlDebugLogger)
val duplicatedChapterCountByMangaId =
ChapterTable
.slice(ChapterTable.manga, ChapterTable.chapter_number, ChapterTable.chapter_number.count())
.select { (ChapterTable.manga inList ids) and (ChapterTable.chapter_number greaterEq 0f) }
.groupBy(ChapterTable.manga, ChapterTable.chapter_number)
.select(ChapterTable.manga, ChapterTable.chapter_number, ChapterTable.chapter_number.count())
.where {
(
ChapterTable.manga inList
ids
) and
(ChapterTable.chapter_number greaterEq 0f)
}.groupBy(ChapterTable.manga, ChapterTable.chapter_number)
.having { ChapterTable.chapter_number.count() greater 1 }
.associate { it[ChapterTable.manga].value to it[ChapterTable.chapter_number.count()] }
@@ -154,7 +167,8 @@ class LastReadChapterForMangaDataLoader : KotlinDataLoader<Int, ChapterType?> {
addLogger(Slf4jSqlDebugLogger)
val lastReadChaptersByMangaId =
ChapterTable
.select { (ChapterTable.manga inList ids) }
.selectAll()
.where { (ChapterTable.manga inList ids) }
.orderBy(ChapterTable.lastReadAt to SortOrder.DESC)
.groupBy { it[ChapterTable.manga].value }
ids.map { id -> lastReadChaptersByMangaId[id]?.let { chapters -> ChapterType(chapters.first()) } }
@@ -173,7 +187,8 @@ class LatestReadChapterForMangaDataLoader : KotlinDataLoader<Int, ChapterType?>
addLogger(Slf4jSqlDebugLogger)
val latestReadChaptersByMangaId =
ChapterTable
.select { (ChapterTable.manga inList ids) and (ChapterTable.isRead eq true) }
.selectAll()
.where { (ChapterTable.manga inList ids) and (ChapterTable.isRead eq true) }
.orderBy(ChapterTable.sourceOrder to SortOrder.DESC)
.groupBy { it[ChapterTable.manga].value }
ids.map { id -> latestReadChaptersByMangaId[id]?.let { chapters -> ChapterType(chapters.first()) } }
@@ -192,7 +207,8 @@ class LatestFetchedChapterForMangaDataLoader : KotlinDataLoader<Int, ChapterType
addLogger(Slf4jSqlDebugLogger)
val latestFetchedChaptersByMangaId =
ChapterTable
.select { (ChapterTable.manga inList ids) }
.selectAll()
.where { (ChapterTable.manga inList ids) }
.orderBy(ChapterTable.fetchedAt to SortOrder.DESC, ChapterTable.sourceOrder to SortOrder.DESC)
.groupBy { it[ChapterTable.manga].value }
ids.map { id -> latestFetchedChaptersByMangaId[id]?.let { chapters -> ChapterType(chapters.first()) } }
@@ -211,7 +227,8 @@ class LatestUploadedChapterForMangaDataLoader : KotlinDataLoader<Int, ChapterTyp
addLogger(Slf4jSqlDebugLogger)
val latestUploadedChaptersByMangaId =
ChapterTable
.select { (ChapterTable.manga inList ids) }
.selectAll()
.where { (ChapterTable.manga inList ids) }
.orderBy(ChapterTable.date_upload to SortOrder.DESC, ChapterTable.sourceOrder to SortOrder.DESC)
.groupBy { it[ChapterTable.manga].value }
ids.map { id -> latestUploadedChaptersByMangaId[id]?.let { chapters -> ChapterType(chapters.first()) } }
@@ -230,7 +247,8 @@ class FirstUnreadChapterForMangaDataLoader : KotlinDataLoader<Int, ChapterType?>
addLogger(Slf4jSqlDebugLogger)
val firstUnreadChaptersByMangaId =
ChapterTable
.select { (ChapterTable.manga inList ids) and (ChapterTable.isRead eq false) }
.selectAll()
.where { (ChapterTable.manga inList ids) and (ChapterTable.isRead eq false) }
.orderBy(ChapterTable.sourceOrder to SortOrder.ASC)
.groupBy { it[ChapterTable.manga].value }
ids.map { id -> firstUnreadChaptersByMangaId[id]?.let { chapters -> ChapterType(chapters.first()) } }

View File

@@ -13,7 +13,7 @@ import org.dataloader.DataLoader
import org.dataloader.DataLoaderFactory
import org.jetbrains.exposed.sql.Slf4jSqlDebugLogger
import org.jetbrains.exposed.sql.addLogger
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.types.ExtensionType
import suwayomi.tachidesk.manga.model.table.ExtensionTable
@@ -30,7 +30,8 @@ class ExtensionDataLoader : KotlinDataLoader<String, ExtensionType?> {
addLogger(Slf4jSqlDebugLogger)
val extensions =
ExtensionTable
.select { ExtensionTable.pkgName inList ids }
.selectAll()
.where { ExtensionTable.pkgName inList ids }
.map { ExtensionType(it) }
.associateBy { it.pkgName }
ids.map { extensions[it] }
@@ -50,7 +51,8 @@ class ExtensionForSourceDataLoader : KotlinDataLoader<Long, ExtensionType?> {
val extensions =
ExtensionTable
.innerJoin(SourceTable)
.select { SourceTable.id inList ids }
.selectAll()
.where { SourceTable.id inList ids }
.toList()
.map { Triple(it[SourceTable.id].value, it[ExtensionTable.pkgName], it) }
.let { triples ->

View File

@@ -15,7 +15,7 @@ import org.dataloader.DataLoaderOptions
import org.jetbrains.exposed.sql.Slf4jSqlDebugLogger
import org.jetbrains.exposed.sql.addLogger
import org.jetbrains.exposed.sql.andWhere
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.cache.CustomCacheMap
import suwayomi.tachidesk.graphql.types.MangaNodeList
@@ -35,7 +35,8 @@ class MangaDataLoader : KotlinDataLoader<Int, MangaType?> {
addLogger(Slf4jSqlDebugLogger)
val manga =
MangaTable
.select { MangaTable.id inList ids }
.selectAll()
.where { MangaTable.id inList ids }
.map { MangaType(it) }
.associateBy { it.id }
ids.map { manga[it] }
@@ -56,7 +57,8 @@ class MangaForCategoryDataLoader : KotlinDataLoader<Int, MangaNodeList> {
if (ids.contains(0)) {
MangaTable
.leftJoin(CategoryMangaTable)
.select { MangaTable.inLibrary eq true }
.selectAll()
.where { MangaTable.inLibrary eq true }
.andWhere { CategoryMangaTable.manga.isNull() }
.map { MangaType(it) }
.let {
@@ -67,7 +69,8 @@ class MangaForCategoryDataLoader : KotlinDataLoader<Int, MangaNodeList> {
} +
CategoryMangaTable
.innerJoin(MangaTable)
.select { CategoryMangaTable.category inList ids }
.selectAll()
.where { CategoryMangaTable.category inList ids }
.map { Pair(it[CategoryMangaTable.category].value, MangaType(it)) }
.groupBy { it.first }
.mapValues { it.value.map { pair -> pair.second } }
@@ -88,7 +91,8 @@ class MangaForSourceDataLoader : KotlinDataLoader<Long, MangaNodeList> {
addLogger(Slf4jSqlDebugLogger)
val mangaBySourceId =
MangaTable
.select { MangaTable.sourceReference inList ids }
.selectAll()
.where { MangaTable.sourceReference inList ids }
.map { MangaType(it) }
.groupBy { it.sourceId }
ids.map { (mangaBySourceId[it] ?: emptyList()).toNodeList() }
@@ -109,7 +113,8 @@ class MangaForIdsDataLoader : KotlinDataLoader<List<Int>, MangaNodeList> {
val ids = mangaIds.flatten().distinct()
val manga =
MangaTable
.select { MangaTable.id inList ids }
.selectAll()
.where { MangaTable.id inList ids }
.map { MangaType(it) }
mangaIds.map { mangaIds ->
manga.filter { it.id in mangaIds }.toNodeList()

View File

@@ -6,7 +6,7 @@ import org.dataloader.DataLoader
import org.dataloader.DataLoaderFactory
import org.jetbrains.exposed.sql.Slf4jSqlDebugLogger
import org.jetbrains.exposed.sql.addLogger
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.global.model.table.GlobalMetaTable
import suwayomi.tachidesk.graphql.types.CategoryMetaType
@@ -30,7 +30,8 @@ class GlobalMetaDataLoader : KotlinDataLoader<String, GlobalMetaType?> {
addLogger(Slf4jSqlDebugLogger)
val metasByRefId =
GlobalMetaTable
.select { GlobalMetaTable.key inList ids }
.selectAll()
.where { GlobalMetaTable.key inList ids }
.map { GlobalMetaType(it) }
.associateBy { it.key }
ids.map { metasByRefId[it] }
@@ -49,7 +50,8 @@ class ChapterMetaDataLoader : KotlinDataLoader<Int, List<ChapterMetaType>> {
addLogger(Slf4jSqlDebugLogger)
val metasByRefId =
ChapterMetaTable
.select { ChapterMetaTable.ref inList ids }
.selectAll()
.where { ChapterMetaTable.ref inList ids }
.map { ChapterMetaType(it) }
.groupBy { it.chapterId }
ids.map { metasByRefId[it].orEmpty() }
@@ -68,7 +70,8 @@ class MangaMetaDataLoader : KotlinDataLoader<Int, List<MangaMetaType>> {
addLogger(Slf4jSqlDebugLogger)
val metasByRefId =
MangaMetaTable
.select { MangaMetaTable.ref inList ids }
.selectAll()
.where { MangaMetaTable.ref inList ids }
.map { MangaMetaType(it) }
.groupBy { it.mangaId }
ids.map { metasByRefId[it].orEmpty() }
@@ -87,7 +90,8 @@ class CategoryMetaDataLoader : KotlinDataLoader<Int, List<CategoryMetaType>> {
addLogger(Slf4jSqlDebugLogger)
val metasByRefId =
CategoryMetaTable
.select { CategoryMetaTable.ref inList ids }
.selectAll()
.where { CategoryMetaTable.ref inList ids }
.map { CategoryMetaType(it) }
.groupBy { it.categoryId }
ids.map { metasByRefId[it].orEmpty() }
@@ -106,7 +110,8 @@ class SourceMetaDataLoader : KotlinDataLoader<Long, List<SourceMetaType>> {
addLogger(Slf4jSqlDebugLogger)
val metasByRefId =
SourceMetaTable
.select { SourceMetaTable.ref inList ids }
.selectAll()
.where { SourceMetaTable.ref inList ids }
.map { SourceMetaType(it) }
.groupBy { it.sourceId }
ids.map { metasByRefId[it].orEmpty() }

View File

@@ -13,7 +13,7 @@ import org.dataloader.DataLoader
import org.dataloader.DataLoaderFactory
import org.jetbrains.exposed.sql.Slf4jSqlDebugLogger
import org.jetbrains.exposed.sql.addLogger
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.types.SourceNodeList
import suwayomi.tachidesk.graphql.types.SourceNodeList.Companion.toNodeList
@@ -32,7 +32,8 @@ class SourceDataLoader : KotlinDataLoader<Long, SourceType?> {
addLogger(Slf4jSqlDebugLogger)
val source =
SourceTable
.select { SourceTable.id inList ids }
.selectAll()
.where { SourceTable.id inList ids }
.mapNotNull { SourceType(it) }
.associateBy { it.id }
ids.map { source[it] }
@@ -53,7 +54,8 @@ class SourcesForExtensionDataLoader : KotlinDataLoader<String, SourceNodeList> {
val sourcesByExtensionPkg =
SourceTable
.innerJoin(ExtensionTable)
.select { ExtensionTable.pkgName inList ids }
.selectAll()
.where { ExtensionTable.pkgName inList ids }
.map { Pair(it[ExtensionTable.pkgName], SourceType(it)) }
.groupBy { it.first }
.mapValues { it.value.mapNotNull { pair -> pair.second } }

View File

@@ -13,7 +13,7 @@ import org.dataloader.DataLoader
import org.dataloader.DataLoaderFactory
import org.jetbrains.exposed.sql.Slf4jSqlDebugLogger
import org.jetbrains.exposed.sql.addLogger
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.types.TrackRecordNodeList
import suwayomi.tachidesk.graphql.types.TrackRecordNodeList.Companion.toNodeList
@@ -91,7 +91,8 @@ class TrackRecordsForMangaIdDataLoader : KotlinDataLoader<Int, TrackRecordNodeLi
addLogger(Slf4jSqlDebugLogger)
val trackRecordsByMangaId =
TrackRecordTable
.select { TrackRecordTable.mangaId inList ids }
.selectAll()
.where { TrackRecordTable.mangaId inList ids }
.map { TrackRecordType(it) }
.groupBy { it.mangaId }
ids.map { (trackRecordsByMangaId[it] ?: emptyList()).toNodeList() }
@@ -110,7 +111,8 @@ class DisplayScoreForTrackRecordDataLoader : KotlinDataLoader<Int, String> {
addLogger(Slf4jSqlDebugLogger)
val trackRecords =
TrackRecordTable
.select { TrackRecordTable.id inList ids }
.selectAll()
.where { TrackRecordTable.id inList ids }
.toList()
.map { it.toTrack() }
.associateBy { it.id!! }
@@ -132,7 +134,8 @@ class TrackRecordsForTrackerIdDataLoader : KotlinDataLoader<Int, TrackRecordNode
addLogger(Slf4jSqlDebugLogger)
val trackRecordsBySyncId =
TrackRecordTable
.select { TrackRecordTable.trackerId inList ids }
.selectAll()
.where { TrackRecordTable.trackerId inList ids }
.map { TrackRecordType(it) }
.groupBy { it.trackerId }
ids.map { (trackRecordsBySyncId[it] ?: emptyList()).toNodeList() }
@@ -151,7 +154,8 @@ class TrackRecordDataLoader : KotlinDataLoader<Int, TrackRecordType> {
addLogger(Slf4jSqlDebugLogger)
val trackRecordsId =
TrackRecordTable
.select { TrackRecordTable.id inList ids }
.selectAll()
.where { TrackRecordTable.id inList ids }
.map { TrackRecordType(it) }
.associateBy { it.id }
ids.map { trackRecordsId[it] }