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

@@ -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()) } }