From 1d541a30ae03fd69ba049d0611eab41c92785146 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sun, 8 Dec 2024 05:49:11 +0100 Subject: [PATCH] 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 --- .../xyz/nulldev/ts/config/ConfigManager.kt | 2 +- .../java/xyz/nulldev/ts/config/Logging.kt | 5 +- .../io/sharedprefs/JavaSharedPreferences.kt | 2 +- .../androidcompat/service/ServiceSupport.kt | 2 +- gradle/libs.versions.toml | 6 +- .../kanade/tachiyomi/network/NetworkHelper.kt | 2 +- .../interceptor/CloudflareInterceptor.kt | 2 +- .../tachiyomi/source/local/LocalSource.kt | 6 +- .../tachidesk/global/impl/GlobalMeta.kt | 3 +- .../tachidesk/graphql/AsDataFetcherResult.kt | 2 +- .../graphql/dataLoaders/CategoryDataLoader.kt | 10 ++-- .../graphql/dataLoaders/ChapterDataLoader.kt | 58 ++++++++++++------- .../dataLoaders/ExtensionDataLoader.kt | 8 ++- .../graphql/dataLoaders/MangaDataLoader.kt | 17 ++++-- .../graphql/dataLoaders/MetaDataLoader.kt | 17 ++++-- .../graphql/dataLoaders/SourceDataLoader.kt | 8 ++- .../graphql/dataLoaders/TrackDataLoader.kt | 14 +++-- .../graphql/mutations/CategoryMutation.kt | 30 +++++----- .../graphql/mutations/ChapterMutation.kt | 18 +++--- .../graphql/mutations/DownloadMutation.kt | 7 ++- .../graphql/mutations/ExtensionMutation.kt | 17 ++++-- .../graphql/mutations/MangaMutation.kt | 16 ++--- .../graphql/mutations/MetaMutation.kt | 5 +- .../graphql/mutations/SourceMutation.kt | 13 +++-- .../graphql/mutations/TrackMutation.kt | 17 ++++-- .../graphql/mutations/UpdateMutation.kt | 4 +- .../graphql/queries/CategoryQuery.kt | 4 +- .../tachidesk/graphql/queries/ChapterQuery.kt | 4 +- .../graphql/queries/ExtensionQuery.kt | 4 +- .../tachidesk/graphql/queries/MangaQuery.kt | 13 ++--- .../tachidesk/graphql/queries/MetaQuery.kt | 4 +- .../tachidesk/graphql/queries/SourceQuery.kt | 4 +- .../tachidesk/graphql/queries/TrackQuery.kt | 4 +- .../graphql/queries/filter/Filter.kt | 52 ++++++++++------- .../graphql/queries/util/CustomDistinctOn.kt | 31 ---------- .../graphql/server/primitives/OrderBy.kt | 2 +- .../ApolloSubscriptionProtocolHandler.kt | 2 +- .../tachidesk/graphql/types/ChapterType.kt | 2 +- .../tachidesk/graphql/types/SourceType.kt | 5 +- .../manga/controller/ExtensionController.kt | 2 +- .../manga/controller/TrackController.kt | 2 +- .../manga/controller/UpdateController.kt | 2 +- .../suwayomi/tachidesk/manga/impl/Category.kt | 22 ++++--- .../tachidesk/manga/impl/CategoryManga.kt | 27 +++++---- .../suwayomi/tachidesk/manga/impl/Chapter.kt | 55 ++++++++++++------ .../suwayomi/tachidesk/manga/impl/Library.kt | 10 ++-- .../suwayomi/tachidesk/manga/impl/Manga.kt | 41 +++++++------ .../tachidesk/manga/impl/MangaList.kt | 10 ++-- .../suwayomi/tachidesk/manga/impl/Page.kt | 13 +++-- .../suwayomi/tachidesk/manga/impl/Source.kt | 11 ++-- .../impl/backup/proto/ProtoBackupExport.kt | 10 ++-- .../impl/backup/proto/ProtoBackupImport.kt | 12 ++-- .../impl/backup/proto/ProtoBackupValidator.kt | 4 +- .../manga/impl/chapter/ChapterForDownload.kt | 11 ++-- .../manga/impl/download/DownloadManager.kt | 11 ++-- .../manga/impl/download/Downloader.kt | 4 +- .../fileProvider/ChaptersFilesProvider.kt | 6 +- .../manga/impl/extension/Extension.kt | 20 ++++--- .../manga/impl/extension/ExtensionsList.kt | 2 +- .../extension/github/ExtensionGithubApi.kt | 2 +- .../tachidesk/manga/impl/track/Track.kt | 28 +++++---- .../impl/track/tracker/TrackerPreferences.kt | 2 +- .../impl/track/tracker/anilist/Anilist.kt | 2 +- .../track/tracker/myanimelist/MyAnimeList.kt | 2 +- .../tachidesk/manga/impl/update/Updater.kt | 2 +- .../manga/impl/update/UpdaterSocket.kt | 2 +- .../manga/impl/util/BytecodeEditor.kt | 2 +- .../tachidesk/manga/impl/util/DirName.kt | 6 +- .../tachidesk/manga/impl/util/GetComicInfo.kt | 5 +- .../tachidesk/manga/impl/util/PackageTools.kt | 2 +- .../impl/util/source/GetCatalogueSource.kt | 8 +-- .../manga/model/table/ChapterTable.kt | 11 +++- .../manga/model/table/TrackSearchTable.kt | 10 ++-- .../suwayomi/tachidesk/server/JavalinSetup.kt | 2 +- .../suwayomi/tachidesk/server/Migration.kt | 2 +- .../suwayomi/tachidesk/server/ServerSetup.kt | 2 +- .../tachidesk/server/database/DBManager.kt | 5 +- .../suwayomi/tachidesk/server/util/AppExit.kt | 2 +- .../tachidesk/server/util/AppMutex.kt | 2 +- .../suwayomi/tachidesk/server/util/Browser.kt | 2 +- .../tachidesk/server/util/SystemTray.kt | 2 +- .../server/util/WebInterfaceManager.kt | 4 +- .../suwayomi/tachidesk/util/HAScheduler.kt | 2 +- .../test/kotlin/masstest/CloudFlareTest.kt | 2 +- .../masstest/TestExtensionCompatibility.kt | 2 +- .../tachidesk/test/ApplicationTest.kt | 2 +- .../suwayomi/tachidesk/test/TestUtils.kt | 2 +- 87 files changed, 459 insertions(+), 355 deletions(-) delete mode 100644 server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/util/CustomDistinctOn.kt diff --git a/AndroidCompat/Config/src/main/java/xyz/nulldev/ts/config/ConfigManager.kt b/AndroidCompat/Config/src/main/java/xyz/nulldev/ts/config/ConfigManager.kt index 3180386fac..468082fcab 100644 --- a/AndroidCompat/Config/src/main/java/xyz/nulldev/ts/config/ConfigManager.kt +++ b/AndroidCompat/Config/src/main/java/xyz/nulldev/ts/config/ConfigManager.kt @@ -14,9 +14,9 @@ import com.typesafe.config.ConfigValue import com.typesafe.config.ConfigValueFactory import com.typesafe.config.parser.ConfigDocument import com.typesafe.config.parser.ConfigDocumentFactory +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock -import mu.KotlinLogging import java.io.File /** diff --git a/AndroidCompat/Config/src/main/java/xyz/nulldev/ts/config/Logging.kt b/AndroidCompat/Config/src/main/java/xyz/nulldev/ts/config/Logging.kt index 97b734781b..dcaf70506e 100644 --- a/AndroidCompat/Config/src/main/java/xyz/nulldev/ts/config/Logging.kt +++ b/AndroidCompat/Config/src/main/java/xyz/nulldev/ts/config/Logging.kt @@ -15,7 +15,8 @@ import ch.qos.logback.core.rolling.RollingFileAppender import ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy import ch.qos.logback.core.util.FileSize import com.typesafe.config.Config -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.DelegatingKLogger +import io.github.oshai.kotlinlogging.KotlinLogging import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -73,7 +74,7 @@ private fun createRollingFileAppender( } private fun getBaseLogger(): ch.qos.logback.classic.Logger = - (KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger) + ((KotlinLogging.logger(Logger.ROOT_LOGGER_NAME) as DelegatingKLogger<*>).underlyingLogger as ch.qos.logback.classic.Logger) private fun getLogger(name: String): ch.qos.logback.classic.Logger { val context = LoggerFactory.getILoggerFactory() as LoggerContext diff --git a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/io/sharedprefs/JavaSharedPreferences.kt b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/io/sharedprefs/JavaSharedPreferences.kt index c48f6d0c55..3e0f4416b0 100644 --- a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/io/sharedprefs/JavaSharedPreferences.kt +++ b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/io/sharedprefs/JavaSharedPreferences.kt @@ -14,11 +14,11 @@ import com.russhwolf.settings.Settings import com.russhwolf.settings.serialization.decodeValue import com.russhwolf.settings.serialization.decodeValueOrNull import com.russhwolf.settings.serialization.encodeValue +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.SerializationException import kotlinx.serialization.builtins.SetSerializer import kotlinx.serialization.builtins.serializer -import mu.KotlinLogging import xyz.nulldev.androidcompat.util.SafePath import xyz.nulldev.ts.config.ApplicationRootDir import java.util.Properties diff --git a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/service/ServiceSupport.kt b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/service/ServiceSupport.kt index b28ba148e5..2f628fa9d8 100644 --- a/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/service/ServiceSupport.kt +++ b/AndroidCompat/src/main/java/xyz/nulldev/androidcompat/service/ServiceSupport.kt @@ -3,7 +3,7 @@ package xyz.nulldev.androidcompat.service import android.app.Service import android.content.Context import android.content.Intent -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.ConcurrentHashMap import kotlin.concurrent.thread diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 527a43a859..94216e51e8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ serialization = "1.7.3" okhttp = "5.0.0-alpha.14" # Major version is locked by Tachiyomi extensions javalin = "6.3.0" jackson = "2.18.2" # jackson version locked by javalin, ref: `io.javalin.core.util.OptionalDependency` -exposed = "0.40.1" +exposed = "0.57.0" dex2jar = "v64" # Stuck until https://github.com/ThexXTURBOXx/dex2jar/issues/27 is fixed polyglot = "24.1.1" settings = "1.3.0" @@ -36,7 +36,7 @@ serialization-xml = { module = "io.github.pdvrieze.xmlutil:serialization-jvm", v # Logging slf4japi = "org.slf4j:slf4j-api:2.0.16" logback = "ch.qos.logback:logback-classic:1.5.12" -kotlinlogging = "io.github.microutils:kotlin-logging:3.0.5" +kotlinlogging = "io.github.oshai:kotlin-logging-jvm:7.0.0" # OkHttp okhttp-core = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } @@ -66,7 +66,7 @@ exposed-javatime = { module = "org.jetbrains.exposed:exposed-java-time", version h2 = "com.h2database:h2:1.4.200" # current database driver, can't update to h2 v2 without sql migration # Exposed Migrations -exposed-migrations = "com.github.Suwayomi:exposed-migrations:3.2.0" +exposed-migrations = "com.github.Suwayomi:exposed-migrations:3.5.0" # Dependency Injection koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" } diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/network/NetworkHelper.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/network/NetworkHelper.kt index bacfa5e93b..6dab5215b7 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/network/NetworkHelper.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/network/NetworkHelper.kt @@ -12,13 +12,13 @@ import eu.kanade.tachiyomi.network.interceptor.CloudflareInterceptor import eu.kanade.tachiyomi.network.interceptor.IgnoreGzipInterceptor import eu.kanade.tachiyomi.network.interceptor.UncaughtExceptionInterceptor import eu.kanade.tachiyomi.network.interceptor.UserAgentInterceptor +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import mu.KotlinLogging import okhttp3.Cache import okhttp3.OkHttpClient import okhttp3.brotli.BrotliInterceptor diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/CloudflareInterceptor.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/CloudflareInterceptor.kt index 00b266a192..cfbe7bbfd6 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/CloudflareInterceptor.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/network/interceptor/CloudflareInterceptor.kt @@ -4,6 +4,7 @@ import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.awaitSuccess import eu.kanade.tachiyomi.network.parseAs +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.map @@ -15,7 +16,6 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import mu.KotlinLogging import okhttp3.Cookie import okhttp3.HttpUrl import okhttp3.Interceptor diff --git a/server/src/main/kotlin/eu/kanade/tachiyomi/source/local/LocalSource.kt b/server/src/main/kotlin/eu/kanade/tachiyomi/source/local/LocalSource.kt index 7e8d42e029..284ab59c2f 100644 --- a/server/src/main/kotlin/eu/kanade/tachiyomi/source/local/LocalSource.kt +++ b/server/src/main/kotlin/eu/kanade/tachiyomi/source/local/LocalSource.kt @@ -26,19 +26,19 @@ import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.util.chapter.ChapterRecognition import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder import eu.kanade.tachiyomi.util.storage.EpubFile +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withContext import kotlinx.serialization.json.Json import kotlinx.serialization.json.decodeFromStream -import mu.KotlinLogging import nl.adaptivity.xmlutil.ExperimentalXmlUtilApi import nl.adaptivity.xmlutil.core.KtXmlReader import nl.adaptivity.xmlutil.serialization.XML import org.apache.commons.compress.archivers.zip.ZipFile import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.insertAndGetId -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.registerCatalogueSource import suwayomi.tachidesk.manga.impl.util.storage.ImageUtil @@ -444,7 +444,7 @@ class LocalSource( fun register() { transaction { - val sourceRecord = SourceTable.select { SourceTable.id eq ID }.firstOrNull() + val sourceRecord = SourceTable.selectAll().where { SourceTable.id eq ID }.firstOrNull() if (sourceRecord == null) { // must do this to avoid database integrity errors diff --git a/server/src/main/kotlin/suwayomi/tachidesk/global/impl/GlobalMeta.kt b/server/src/main/kotlin/suwayomi/tachidesk/global/impl/GlobalMeta.kt index caab68edaf..0feacc200a 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/global/impl/GlobalMeta.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/global/impl/GlobalMeta.kt @@ -1,7 +1,6 @@ package suwayomi.tachidesk.global.impl import org.jetbrains.exposed.sql.insert -import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update @@ -22,7 +21,7 @@ object GlobalMeta { transaction { val meta = transaction { - GlobalMetaTable.select { GlobalMetaTable.key eq key } + GlobalMetaTable.selectAll().where { GlobalMetaTable.key eq key } }.firstOrNull() if (meta == null) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/AsDataFetcherResult.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/AsDataFetcherResult.kt index f1e71d032d..6c3a0f74a2 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/AsDataFetcherResult.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/AsDataFetcherResult.kt @@ -2,7 +2,7 @@ package suwayomi.tachidesk.graphql import com.expediagroup.graphql.server.extensions.toGraphQLError import graphql.execution.DataFetcherResult -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging val logger = KotlinLogging.logger { } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/CategoryDataLoader.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/CategoryDataLoader.kt index 8af0b609ad..12c83b6257 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/CategoryDataLoader.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/CategoryDataLoader.kt @@ -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 { 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, 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 { 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 } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/ChapterDataLoader.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/ChapterDataLoader.kt index 8e22d1cd21..ad768decf8 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/ChapterDataLoader.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/ChapterDataLoader.kt @@ -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 { 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 { 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 { 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 { 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 { 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 { 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 { 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 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 latestFetchedChaptersByMangaId[id]?.let { chapters -> ChapterType(chapters.first()) } } @@ -211,7 +227,8 @@ class LatestUploadedChapterForMangaDataLoader : KotlinDataLoader latestUploadedChaptersByMangaId[id]?.let { chapters -> ChapterType(chapters.first()) } } @@ -230,7 +247,8 @@ class FirstUnreadChapterForMangaDataLoader : KotlinDataLoader 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()) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/ExtensionDataLoader.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/ExtensionDataLoader.kt index 177ffa2b28..2c7be2fa68 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/ExtensionDataLoader.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/ExtensionDataLoader.kt @@ -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 { 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 { 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 -> 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 5d76add13b..0775d71ad8 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/MangaDataLoader.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/MangaDataLoader.kt @@ -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 { 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 { 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 { } + 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 { 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, 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() diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/MetaDataLoader.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/MetaDataLoader.kt index e9023a74cf..a01f2392ca 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/MetaDataLoader.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/MetaDataLoader.kt @@ -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 { 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> { 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> { 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> { 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> { 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() } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/SourceDataLoader.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/SourceDataLoader.kt index 5cd0658a27..be3c60e0be 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/SourceDataLoader.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/SourceDataLoader.kt @@ -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 { 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 { 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 } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/TrackDataLoader.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/TrackDataLoader.kt index 176d9c30a2..6a900a2c5d 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/TrackDataLoader.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/dataLoaders/TrackDataLoader.kt @@ -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 { 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 { 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] } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/CategoryMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/CategoryMutation.kt index fa1de3951b..e22e05fa5f 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/CategoryMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/CategoryMutation.kt @@ -9,7 +9,6 @@ import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.batchInsert import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.insertAndGetId -import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update @@ -67,14 +66,15 @@ class CategoryMutation { transaction { val meta = CategoryMetaTable - .select { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) } + .selectAll() + .where { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) } .firstOrNull() CategoryMetaTable.deleteWhere { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) } val category = transaction { - CategoryType(CategoryTable.select { CategoryTable.id eq categoryId }.first()) + CategoryType(CategoryTable.selectAll().where { CategoryTable.id eq categoryId }.first()) } if (meta != null) { @@ -160,7 +160,7 @@ class CategoryMutation { val category = transaction { - CategoryType(CategoryTable.select { CategoryTable.id eq id }.first()) + CategoryType(CategoryTable.selectAll().where { CategoryTable.id eq id }.first()) } UpdateCategoryPayload( @@ -177,7 +177,7 @@ class CategoryMutation { val categories = transaction { - CategoryTable.select { CategoryTable.id inList ids }.map { CategoryType(it) } + CategoryTable.selectAll().where { CategoryTable.id inList ids }.map { CategoryType(it) } } UpdateCategoriesPayload( @@ -207,7 +207,8 @@ class CategoryMutation { transaction { val currentOrder = CategoryTable - .select { CategoryTable.id eq categoryId } + .selectAll() + .where { CategoryTable.id eq categoryId } .first()[CategoryTable.order] if (currentOrder != position) { @@ -258,7 +259,7 @@ class CategoryMutation { asDataFetcherResult { val (clientMutationId, name, order, default, includeInUpdate, includeInDownload) = input transaction { - require(CategoryTable.select { CategoryTable.name eq input.name }.isEmpty()) { + require(CategoryTable.selectAll().where { CategoryTable.name eq input.name }.isEmpty()) { "'name' must be unique" } } @@ -296,7 +297,7 @@ class CategoryMutation { Category.normalizeCategories() - CategoryType(CategoryTable.select { CategoryTable.id eq id }.first()) + CategoryType(CategoryTable.selectAll().where { CategoryTable.id eq id }.first()) } CreateCategoryPayload(clientMutationId, category) @@ -328,14 +329,16 @@ class CategoryMutation { transaction { val category = CategoryTable - .select { CategoryTable.id eq categoryId } + .selectAll() + .where { CategoryTable.id eq categoryId } .firstOrNull() val mangas = transaction { MangaTable .innerJoin(CategoryMangaTable) - .select { CategoryMangaTable.category eq categoryId } + .selectAll() + .where { CategoryMangaTable.category eq categoryId } .map { MangaType(it) } } @@ -401,7 +404,8 @@ class CategoryMutation { patch.addToCategories.forEach { categoryId -> val existingMapping = CategoryMangaTable - .select { + .selectAll() + .where { (CategoryMangaTable.manga eq mangaId) and (CategoryMangaTable.category eq categoryId) }.isNotEmpty() @@ -428,7 +432,7 @@ class CategoryMutation { val manga = transaction { - MangaType(MangaTable.select { MangaTable.id eq id }.first()) + MangaType(MangaTable.selectAll().where { MangaTable.id eq id }.first()) } UpdateMangaCategoriesPayload( @@ -445,7 +449,7 @@ class CategoryMutation { val mangas = transaction { - MangaTable.select { MangaTable.id inList ids }.map { MangaType(it) } + MangaTable.selectAll().where { MangaTable.id inList ids }.map { MangaType(it) } } UpdateMangasCategoriesPayload( diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt index 0d60f3f4c9..5c80929336 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt @@ -5,7 +5,7 @@ import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.deleteWhere -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.statements.BatchUpdateStatement import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.graphql.asDataFetcherResult @@ -65,8 +65,8 @@ class ChapterMutation { val chapterIdToPageCount = if (patch.lastPageRead != null) { ChapterTable - .slice(ChapterTable.id, ChapterTable.pageCount) - .select { ChapterTable.id inList ids } + .select(ChapterTable.id, ChapterTable.pageCount) + .where { ChapterTable.id inList ids } .groupBy { it[ChapterTable.id].value } .mapValues { it.value.firstOrNull()?.let { it[ChapterTable.pageCount] } } } else { @@ -103,7 +103,7 @@ class ChapterMutation { val chapter = transaction { - ChapterType(ChapterTable.select { ChapterTable.id eq id }.first()) + ChapterType(ChapterTable.selectAll().where { ChapterTable.id eq id }.first()) } UpdateChapterPayload( @@ -120,7 +120,7 @@ class ChapterMutation { val chapters = transaction { - ChapterTable.select { ChapterTable.id inList ids }.map { ChapterType(it) } + ChapterTable.selectAll().where { ChapterTable.id inList ids }.map { ChapterType(it) } } UpdateChaptersPayload( @@ -149,7 +149,8 @@ class ChapterMutation { val chapters = transaction { ChapterTable - .select { ChapterTable.manga eq mangaId } + .selectAll() + .where { ChapterTable.manga eq mangaId } .orderBy(ChapterTable.sourceOrder) .map { ChapterType(it) } } @@ -201,14 +202,15 @@ class ChapterMutation { transaction { val meta = ChapterMetaTable - .select { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) } + .selectAll() + .where { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) } .firstOrNull() ChapterMetaTable.deleteWhere { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) } val chapter = transaction { - ChapterType(ChapterTable.select { ChapterTable.id eq chapterId }.first()) + ChapterType(ChapterTable.selectAll().where { ChapterTable.id eq chapterId }.first()) } if (meta != null) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/DownloadMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/DownloadMutation.kt index e9a2b470be..1d326f63ff 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/DownloadMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/DownloadMutation.kt @@ -3,7 +3,7 @@ package suwayomi.tachidesk.graphql.mutations import graphql.execution.DataFetcherResult import kotlinx.coroutines.flow.first import kotlinx.coroutines.withTimeout -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.graphql.asDataFetcherResult import suwayomi.tachidesk.graphql.types.ChapterType @@ -39,7 +39,8 @@ class DownloadMutation { chapters = transaction { ChapterTable - .select { ChapterTable.id inList chapters } + .selectAll() + .where { ChapterTable.id inList chapters } .map { ChapterType(it) } }, ) @@ -66,7 +67,7 @@ class DownloadMutation { clientMutationId = clientMutationId, chapters = transaction { - ChapterType(ChapterTable.select { ChapterTable.id eq chapter }.first()) + ChapterType(ChapterTable.selectAll().where { ChapterTable.id eq chapter }.first()) }, ) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ExtensionMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ExtensionMutation.kt index 83a65c8c29..d74b7b1dbc 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ExtensionMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ExtensionMutation.kt @@ -3,7 +3,7 @@ package suwayomi.tachidesk.graphql.mutations import eu.kanade.tachiyomi.source.local.LocalSource import graphql.execution.DataFetcherResult import io.javalin.http.UploadedFile -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.graphql.asDataFetcherResult import suwayomi.tachidesk.graphql.types.ExtensionType @@ -49,7 +49,8 @@ class ExtensionMutation { val extensions = transaction { ExtensionTable - .select { ExtensionTable.pkgName inList ids } + .selectAll() + .where { ExtensionTable.pkgName inList ids } .map { ExtensionType(it) } } @@ -82,7 +83,8 @@ class ExtensionMutation { val extension = transaction { ExtensionTable - .select { ExtensionTable.pkgName eq id } + .selectAll() + .where { ExtensionTable.pkgName eq id } .firstOrNull() ?.let { ExtensionType(it) } } @@ -105,7 +107,8 @@ class ExtensionMutation { val extensions = transaction { ExtensionTable - .select { ExtensionTable.pkgName inList ids } + .selectAll() + .where { ExtensionTable.pkgName inList ids } .map { ExtensionType(it) } } @@ -136,7 +139,8 @@ class ExtensionMutation { val extensions = transaction { ExtensionTable - .select { ExtensionTable.name neq LocalSource.EXTENSION_NAME } + .selectAll() + .where { ExtensionTable.name neq LocalSource.EXTENSION_NAME } .map { ExtensionType(it) } } @@ -167,7 +171,8 @@ class ExtensionMutation { asDataFetcherResult { Extension.installExternalExtension(extensionFile.content(), extensionFile.filename()) - val dbExtension = transaction { ExtensionTable.select { ExtensionTable.apkName eq extensionFile.filename() }.first() } + val dbExtension = + transaction { ExtensionTable.selectAll().where { ExtensionTable.apkName eq extensionFile.filename() }.first() } InstallExternalExtensionPayload( clientMutationId, diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt index d53f22f759..1e7322a342 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt @@ -4,7 +4,7 @@ import graphql.execution.DataFetcherResult import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.deleteWhere -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update import suwayomi.tachidesk.graphql.asDataFetcherResult @@ -75,7 +75,8 @@ class MangaMutation { val mangas = transaction { MangaTable - .select { (MangaTable.id inList ids) and (MangaTable.initialized eq false) } + .selectAll() + .where { (MangaTable.id inList ids) and (MangaTable.initialized eq false) } .map { MangaTable.toDataClass(it) } } @@ -98,7 +99,7 @@ class MangaMutation { val manga = transaction { - MangaType(MangaTable.select { MangaTable.id eq id }.first()) + MangaType(MangaTable.selectAll().where { MangaTable.id eq id }.first()) } UpdateMangaPayload( @@ -118,7 +119,7 @@ class MangaMutation { val mangas = transaction { - MangaTable.select { MangaTable.id inList ids }.map { MangaType(it) } + MangaTable.selectAll().where { MangaTable.id inList ids }.map { MangaType(it) } } UpdateMangasPayload( @@ -148,7 +149,7 @@ class MangaMutation { val manga = transaction { - MangaTable.select { MangaTable.id eq id }.first() + MangaTable.selectAll().where { MangaTable.id eq id }.first() } FetchMangaPayload( clientMutationId = clientMutationId, @@ -198,14 +199,15 @@ class MangaMutation { transaction { val meta = MangaMetaTable - .select { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) } + .selectAll() + .where { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) } .firstOrNull() MangaMetaTable.deleteWhere { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) } val manga = transaction { - MangaType(MangaTable.select { MangaTable.id eq mangaId }.first()) + MangaType(MangaTable.selectAll().where { MangaTable.id eq mangaId }.first()) } if (meta != null) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MetaMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MetaMutation.kt index acc3e25a34..e83b1cf850 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MetaMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MetaMutation.kt @@ -3,7 +3,7 @@ package suwayomi.tachidesk.graphql.mutations import graphql.execution.DataFetcherResult import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.deleteWhere -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.global.impl.GlobalMeta import suwayomi.tachidesk.global.model.table.GlobalMetaTable @@ -49,7 +49,8 @@ class MetaMutation { transaction { val meta = GlobalMetaTable - .select { GlobalMetaTable.key eq key } + .selectAll() + .where { GlobalMetaTable.key eq key } .firstOrNull() GlobalMetaTable.deleteWhere { GlobalMetaTable.key eq key } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/SourceMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/SourceMutation.kt index 3a46d0c7bb..f47d054134 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/SourceMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/SourceMutation.kt @@ -9,7 +9,7 @@ import graphql.execution.DataFetcherResult import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.deleteWhere -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.graphql.asDataFetcherResult import suwayomi.tachidesk.graphql.types.FilterChange @@ -69,7 +69,8 @@ class SourceMutation { transaction { val meta = SourceMetaTable - .select { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) } + .selectAll() + .where { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) } .firstOrNull() SourceMetaTable.deleteWhere { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) } @@ -77,7 +78,8 @@ class SourceMutation { val source = transaction { SourceTable - .select { SourceTable.id eq sourceId } + .selectAll() + .where { SourceTable.id eq sourceId } .firstOrNull() ?.let { SourceType(it) } } @@ -143,7 +145,8 @@ class SourceMutation { val mangas = transaction { MangaTable - .select { MangaTable.id inList mangaIds } + .selectAll() + .where { MangaTable.id inList mangaIds } .map { MangaType(it) } }.sortedBy { mangaIds.indexOf(it.id) @@ -199,7 +202,7 @@ class SourceMutation { preferences = Source.getSourcePreferencesRaw(sourceId).map { preferenceOf(it) }, source = transaction { - SourceType(SourceTable.select { SourceTable.id eq sourceId }.first())!! + SourceType(SourceTable.selectAll().where { SourceTable.id eq sourceId }.first())!! }, ) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/TrackMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/TrackMutation.kt index 0bf73467db..5e2f264809 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/TrackMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/TrackMutation.kt @@ -4,7 +4,7 @@ import com.expediagroup.graphql.generator.annotations.GraphQLDeprecated import com.expediagroup.graphql.generator.annotations.GraphQLDescription import graphql.execution.DataFetcherResult import org.jetbrains.exposed.sql.and -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.graphql.asDataFetcherResult import suwayomi.tachidesk.graphql.types.TrackRecordType @@ -127,7 +127,8 @@ class TrackMutation { val trackRecord = transaction { TrackRecordTable - .select { + .selectAll() + .where { TrackRecordTable.mangaId eq mangaId and (TrackRecordTable.trackerId eq trackerId) }.first() } @@ -156,7 +157,8 @@ class TrackMutation { val trackRecord = transaction { TrackRecordTable - .select { + .selectAll() + .where { TrackRecordTable.id eq recordId }.first() } @@ -187,7 +189,8 @@ class TrackMutation { val trackRecord = transaction { TrackRecordTable - .select { + .selectAll() + .where { TrackRecordTable.id eq recordId }.firstOrNull() } @@ -217,7 +220,8 @@ class TrackMutation { val trackRecords = transaction { TrackRecordTable - .select { TrackRecordTable.mangaId eq mangaId } + .selectAll() + .where { TrackRecordTable.mangaId eq mangaId } .toList() } TrackProgressPayload( @@ -262,7 +266,8 @@ class TrackMutation { val trackRecord = transaction { TrackRecordTable - .select { + .selectAll() + .where { TrackRecordTable.id eq input.recordId }.firstOrNull() } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/UpdateMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/UpdateMutation.kt index 92c6f16d5c..08a3cb0a74 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/UpdateMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/UpdateMutation.kt @@ -3,7 +3,7 @@ package suwayomi.tachidesk.graphql.mutations import graphql.execution.DataFetcherResult import kotlinx.coroutines.flow.first import kotlinx.coroutines.withTimeout -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.graphql.asDataFetcherResult import suwayomi.tachidesk.graphql.types.UpdateStatus @@ -61,7 +61,7 @@ class UpdateMutation { fun updateCategoryManga(input: UpdateCategoryMangaInput): CompletableFuture> { val categories = transaction { - CategoryTable.select { CategoryTable.id inList input.categories }.map { + CategoryTable.selectAll().where { CategoryTable.id inList input.categories }.map { CategoryTable.toDataClass(it) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/CategoryQuery.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/CategoryQuery.kt index 30fc5997d7..46526bf4aa 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/CategoryQuery.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/CategoryQuery.kt @@ -48,7 +48,7 @@ class CategoryQuery { ): CompletableFuture = dataFetchingEnvironment.getValueFromDataLoader("CategoryDataLoader", id) enum class CategoryOrderBy( - override val column: Column>, + override val column: Column<*>, ) : OrderBy { ID(CategoryTable.id), NAME(CategoryTable.name), @@ -170,7 +170,7 @@ class CategoryQuery { ) if (first != null) { - res.limit(first, offset?.toLong() ?: 0) + res.limit(first).offset(offset?.toLong() ?: 0) } else if (last != null) { res.limit(last) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/ChapterQuery.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/ChapterQuery.kt index 9cb989b56d..9f5776acb9 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/ChapterQuery.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/ChapterQuery.kt @@ -57,7 +57,7 @@ class ChapterQuery { ): CompletableFuture = dataFetchingEnvironment.getValueFromDataLoader("ChapterDataLoader", id) enum class ChapterOrderBy( - override val column: Column>, + override val column: Column<*>, ) : OrderBy { ID(ChapterTable.id), SOURCE_ORDER(ChapterTable.sourceOrder), @@ -254,7 +254,7 @@ class ChapterQuery { ) if (first != null) { - res.limit(first, offset?.toLong() ?: 0) + res.limit(first).offset(offset?.toLong() ?: 0) } else if (last != null) { res.limit(last) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/ExtensionQuery.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/ExtensionQuery.kt index 6232a86203..10f855ee19 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/ExtensionQuery.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/ExtensionQuery.kt @@ -49,7 +49,7 @@ class ExtensionQuery { ): CompletableFuture = dataFetchingEnvironment.getValueFromDataLoader("ExtensionDataLoader", pkgName) enum class ExtensionOrderBy( - override val column: Column>, + override val column: Column<*>, ) : OrderBy { PKG_NAME(ExtensionTable.pkgName), NAME(ExtensionTable.name), @@ -204,7 +204,7 @@ class ExtensionQuery { ) if (first != null) { - res.limit(first, offset?.toLong() ?: 0) + res.limit(first).offset(offset?.toLong() ?: 0) } else if (last != null) { res.limit(last) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/MangaQuery.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/MangaQuery.kt index 29d7ab6733..d823f90db4 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/MangaQuery.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/MangaQuery.kt @@ -15,7 +15,6 @@ import org.jetbrains.exposed.sql.Op import org.jetbrains.exposed.sql.SortOrder import org.jetbrains.exposed.sql.SqlExpressionBuilder.greater import org.jetbrains.exposed.sql.SqlExpressionBuilder.less -import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.graphql.queries.filter.BooleanFilter import suwayomi.tachidesk.graphql.queries.filter.ComparableScalarFilter @@ -29,7 +28,6 @@ import suwayomi.tachidesk.graphql.queries.filter.andFilterWithCompare import suwayomi.tachidesk.graphql.queries.filter.andFilterWithCompareEntity import suwayomi.tachidesk.graphql.queries.filter.andFilterWithCompareString import suwayomi.tachidesk.graphql.queries.filter.applyOps -import suwayomi.tachidesk.graphql.queries.util.distinctOn import suwayomi.tachidesk.graphql.server.primitives.Cursor import suwayomi.tachidesk.graphql.server.primitives.Order import suwayomi.tachidesk.graphql.server.primitives.OrderBy @@ -53,7 +51,7 @@ class MangaQuery { ): CompletableFuture = dataFetchingEnvironment.getValueFromDataLoader("MangaDataLoader", id) enum class MangaOrderBy( - override val column: Column>, + override val column: Column<*>, ) : OrderBy { ID(MangaTable.id), TITLE(MangaTable.title), @@ -242,11 +240,8 @@ class MangaQuery { val res = MangaTable .leftJoin(CategoryMangaTable) - .slice( - distinctOn(MangaTable.id), - *(MangaTable.columns).toTypedArray(), - *(CategoryMangaTable.columns).toTypedArray(), - ).selectAll() + .select(MangaTable.columns) + .withDistinctOn(MangaTable.id) res.applyOps(condition, filter) @@ -274,7 +269,7 @@ class MangaQuery { ) if (first != null) { - res.limit(first, offset?.toLong() ?: 0) + res.limit(first).offset(offset?.toLong() ?: 0) } else if (last != null) { res.limit(last) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/MetaQuery.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/MetaQuery.kt index ef518dc2c2..a00b3a5a19 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/MetaQuery.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/MetaQuery.kt @@ -44,7 +44,7 @@ class MetaQuery { ): CompletableFuture = dataFetchingEnvironment.getValueFromDataLoader("GlobalMetaDataLoader", key) enum class MetaOrderBy( - override val column: Column>, + override val column: Column<*>, ) : OrderBy { KEY(GlobalMetaTable.key), VALUE(GlobalMetaTable.value), @@ -154,7 +154,7 @@ class MetaQuery { ) if (first != null) { - res.limit(first, offset?.toLong() ?: 0) + res.limit(first).offset(offset?.toLong() ?: 0) } else if (last != null) { res.limit(last) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/SourceQuery.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/SourceQuery.kt index 784f41c7f0..8c0667fcb3 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/SourceQuery.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/SourceQuery.kt @@ -48,7 +48,7 @@ class SourceQuery { ): CompletableFuture = dataFetchingEnvironment.getValueFromDataLoader("SourceDataLoader", id) enum class SourceOrderBy( - override val column: Column>, + override val column: Column<*>, ) : OrderBy { ID(SourceTable.id), NAME(SourceTable.name), @@ -170,7 +170,7 @@ class SourceQuery { ) if (first != null) { - res.limit(first, offset?.toLong() ?: 0) + res.limit(first).offset(offset?.toLong() ?: 0) } else if (last != null) { res.limit(last) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/TrackQuery.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/TrackQuery.kt index c713a7bcc8..22ebec1b41 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/TrackQuery.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/TrackQuery.kt @@ -244,7 +244,7 @@ class TrackQuery { dataFetchingEnvironment.getValueFromDataLoader("TrackRecordDataLoader", id) enum class TrackRecordOrderBy( - override val column: Column>, + override val column: Column<*>, ) : OrderBy { ID(TrackRecordTable.id), MANGA_ID(TrackRecordTable.mangaId), @@ -430,7 +430,7 @@ class TrackQuery { ) if (first != null) { - res.limit(first, offset?.toLong() ?: 0) + res.limit(first).offset(offset?.toLong() ?: 0) } else if (last != null) { res.limit(last) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/filter/Filter.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/filter/Filter.kt index 0713ead8fe..19a4c077ba 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/filter/Filter.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/filter/Filter.kt @@ -466,12 +466,12 @@ fun andFilterWithCompareString( } opAnd.andWhere(filter.distinctFromInsensitive, filter.distinctFromInsensitiveAll, filter.distinctFromInsensitiveAny) { - DistinctFromOp.distinctFrom(column.upperCase(), it.uppercase() as S) + DistinctFromOp.distinctFrom(column.upperCase(), it.uppercase()) } - opAnd.andWhere(filter.notDistinctFromInsensitive) { DistinctFromOp.notDistinctFrom(column.upperCase(), it.uppercase() as S) } + opAnd.andWhere(filter.notDistinctFromInsensitive) { DistinctFromOp.notDistinctFrom(column.upperCase(), it.uppercase()) } - opAnd.andWhere(filter.inInsensitive) { column.upperCase() inList (it.map { it.uppercase() } as List) } - opAnd.andWhere(filter.notInInsensitive) { column.upperCase() notInList (it.map { it.uppercase() } as List) } + opAnd.andWhere(filter.inInsensitive) { column.upperCase() inList (it.map { it.uppercase() }) } + opAnd.andWhere(filter.notInInsensitive) { column.upperCase() notInList (it.map { it.uppercase() }) } opAnd.andWhere(filter.lessThanInsensitive) { column.upperCase() less it.uppercase() } opAnd.andWhere(filter.lessThanOrEqualToInsensitive) { column.upperCase() lessEq it.uppercase() } @@ -539,47 +539,59 @@ class OpAnd( ) = andWhere(value) { column eq it } } +@Suppress("UNCHECKED_CAST") fun , S : T?> andFilterWithCompare( column: Column, filter: ComparableScalarFilter?, ): Op? { filter ?: return null - val opAnd = OpAnd(andFilter(column, filter)) + val opAnd = OpAnd() opAnd.andWhere(filter.lessThan) { column less it } opAnd.andWhere(filter.lessThanOrEqualTo) { column lessEq it } opAnd.andWhere(filter.greaterThan) { column greater it } opAnd.andWhere(filter.greaterThanOrEqualTo) { column greaterEq it } + opAnd.andWhere(filter.isNull) { if (it) column.isNull() else column.isNotNull() } + + opAnd.andWhere(filter.equalTo) { column eq it as S } + opAnd.andWhere(filter.notEqualTo, filter.notEqualToAll, filter.notEqualToAny) { column neq it as S } + opAnd.andWhere(filter.distinctFrom, filter.distinctFromAll, filter.distinctFromAny) { DistinctFromOp.distinctFrom(column, it as S) } + opAnd.andWhere(filter.notDistinctFrom) { DistinctFromOp.notDistinctFrom(column, it as S) } + if (!filter.`in`.isNullOrEmpty()) { + opAnd.andWhere(filter.`in`) { column inList it as List } + } + if (!filter.notIn.isNullOrEmpty()) { + opAnd.andWhere(filter.notIn) { column notInList it as List } + } + return opAnd.op } fun > andFilterWithCompareEntity( column: Column>, filter: ComparableScalarFilter?, -): Op? { - @Suppress("UNCHECKED_CAST") - return andFilterWithCompare(column as Column, filter) -} - -@Suppress("UNCHECKED_CAST") -fun , S : T?> andFilter( - column: Column, - filter: ScalarFilter?, ): Op? { filter ?: return null val opAnd = OpAnd() + opAnd.andWhere(filter.lessThan) { column less it } + opAnd.andWhere(filter.lessThanOrEqualTo) { column lessEq it } + opAnd.andWhere(filter.greaterThan) { column greater it } + opAnd.andWhere(filter.greaterThanOrEqualTo) { column greaterEq it } + opAnd.andWhere(filter.isNull) { if (it) column.isNull() else column.isNotNull() } - opAnd.andWhere(filter.equalTo) { column eq it as S } - opAnd.andWhere(filter.notEqualTo, filter.notEqualToAll, filter.notEqualToAny) { column neq it as S } - opAnd.andWhere(filter.distinctFrom, filter.distinctFromAll, filter.distinctFromAny) { DistinctFromOp.distinctFrom(column, it as S) } - opAnd.andWhere(filter.notDistinctFrom) { DistinctFromOp.notDistinctFrom(column, it as S) } + + opAnd.andWhere(filter.equalTo) { column eq it } + opAnd.andWhere(filter.notEqualTo, filter.notEqualToAll, filter.notEqualToAny) { column neq it } + opAnd.andWhere(filter.distinctFrom, filter.distinctFromAll, filter.distinctFromAny) { DistinctFromOp.distinctFrom(column, it) } + opAnd.andWhere(filter.notDistinctFrom) { DistinctFromOp.notDistinctFrom(column, it) } if (!filter.`in`.isNullOrEmpty()) { - opAnd.andWhere(filter.`in`) { column inList it as List } + opAnd.andWhere(filter.`in`) { column inList it } } if (!filter.notIn.isNullOrEmpty()) { - opAnd.andWhere(filter.notIn) { column notInList it as List } + opAnd.andWhere(filter.notIn) { column notInList it } } + return opAnd.op } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/util/CustomDistinctOn.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/util/CustomDistinctOn.kt deleted file mode 100644 index b91122b509..0000000000 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/util/CustomDistinctOn.kt +++ /dev/null @@ -1,31 +0,0 @@ -package suwayomi.tachidesk.graphql.queries.util - -import org.jetbrains.exposed.sql.BooleanColumnType -import org.jetbrains.exposed.sql.CustomFunction -import org.jetbrains.exposed.sql.Expression -import org.jetbrains.exposed.sql.QueryBuilder - -/** - * src: https://github.com/JetBrains/Exposed/issues/500#issuecomment-543574151 (2024-04-02 02:20) - */ - -fun distinctOn(vararg expressions: Expression<*>): CustomFunction = - customBooleanFunction( - functionName = "DISTINCT ON", - postfix = " TRUE", - params = expressions, - ) - -fun customBooleanFunction( - functionName: String, - postfix: String = "", - vararg params: Expression<*>, -): CustomFunction = - object : CustomFunction(functionName, BooleanColumnType(), *params) { - override fun toQueryBuilder(queryBuilder: QueryBuilder) { - super.toQueryBuilder(queryBuilder) - if (postfix.isNotEmpty()) { - queryBuilder.append(postfix) - } - } - } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/primitives/OrderBy.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/primitives/OrderBy.kt index 2ac1fc4ca0..d0b495c398 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/primitives/OrderBy.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/primitives/OrderBy.kt @@ -13,7 +13,7 @@ import org.jetbrains.exposed.sql.andWhere import org.jetbrains.exposed.sql.or interface OrderBy { - val column: Column> + val column: Column<*> fun asCursor(type: T): Cursor diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/subscriptions/ApolloSubscriptionProtocolHandler.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/subscriptions/ApolloSubscriptionProtocolHandler.kt index accda722f0..abbf873cb5 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/subscriptions/ApolloSubscriptionProtocolHandler.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/subscriptions/ApolloSubscriptionProtocolHandler.kt @@ -12,6 +12,7 @@ import com.expediagroup.graphql.server.types.GraphQLRequest import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.kotlin.convertValue import com.fasterxml.jackson.module.kotlin.readValue +import io.github.oshai.kotlinlogging.KotlinLogging import io.javalin.websocket.WsContext import io.javalin.websocket.WsMessageContext import kotlinx.coroutines.currentCoroutineContext @@ -24,7 +25,6 @@ import kotlinx.coroutines.flow.onCompletion import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.job import kotlinx.coroutines.runBlocking -import mu.KotlinLogging import org.eclipse.jetty.websocket.api.CloseStatus import suwayomi.tachidesk.graphql.server.TachideskGraphQLContextFactory import suwayomi.tachidesk.graphql.server.subscriptions.SubscriptionOperationMessage.ClientMessages.GQL_CONNECTION_INIT diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/ChapterType.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/ChapterType.kt index 2520dcac6c..e12d4b7c42 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/ChapterType.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/ChapterType.kt @@ -68,7 +68,7 @@ class ChapterType( row[ChapterTable.fetchedAt], row[ChapterTable.isDownloaded], row[ChapterTable.pageCount], -// transaction { ChapterTable.select { manga eq chapterEntry[manga].value }.count().toInt() }, +// transaction { ChapterTable.selectAll().where { Manga eq chapterEntry[manga].value }.count().toInt() }, ) constructor(dataClass: ChapterDataClass) : this( diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/SourceType.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/SourceType.kt index 9c63395e14..e0dbdc8384 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/SourceType.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/SourceType.kt @@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.source.ConfigurableSource import eu.kanade.tachiyomi.source.model.FilterList import graphql.schema.DataFetchingEnvironment import org.jetbrains.exposed.sql.ResultRow -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import suwayomi.tachidesk.graphql.server.primitives.Cursor import suwayomi.tachidesk.graphql.server.primitives.Edge import suwayomi.tachidesk.graphql.server.primitives.Node @@ -92,7 +92,8 @@ fun SourceType(row: ResultRow): SourceType? { row } else { ExtensionTable - .select { ExtensionTable.id eq row[SourceTable.extension] } + .selectAll() + .where { ExtensionTable.id eq row[SourceTable.extension] } .first() } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/ExtensionController.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/ExtensionController.kt index 9b43d9de43..ebea9427bd 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/ExtensionController.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/ExtensionController.kt @@ -7,8 +7,8 @@ package suwayomi.tachidesk.manga.controller * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +import io.github.oshai.kotlinlogging.KotlinLogging import io.javalin.http.HttpStatus -import mu.KotlinLogging import suwayomi.tachidesk.manga.impl.extension.Extension import suwayomi.tachidesk.manga.impl.extension.ExtensionsList import suwayomi.tachidesk.manga.model.dataclass.ExtensionDataClass diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/TrackController.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/TrackController.kt index 28541091d5..e606bdd4dd 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/TrackController.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/TrackController.kt @@ -7,9 +7,9 @@ package suwayomi.tachidesk.manga.controller * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +import io.github.oshai.kotlinlogging.KotlinLogging import io.javalin.http.HttpStatus import kotlinx.serialization.json.Json -import mu.KotlinLogging import suwayomi.tachidesk.manga.impl.track.Track import suwayomi.tachidesk.manga.model.dataclass.TrackerDataClass import suwayomi.tachidesk.server.JavalinSetup.future diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/UpdateController.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/UpdateController.kt index d7869a9085..d9c93fccdb 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/UpdateController.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/controller/UpdateController.kt @@ -1,8 +1,8 @@ package suwayomi.tachidesk.manga.controller +import io.github.oshai.kotlinlogging.KotlinLogging import io.javalin.http.HttpStatus import io.javalin.websocket.WsConfig -import mu.KotlinLogging import suwayomi.tachidesk.manga.impl.Category import suwayomi.tachidesk.manga.impl.Chapter import suwayomi.tachidesk.manga.impl.update.IUpdater diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Category.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Category.kt index a52fed0bfa..6dc65da57d 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Category.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Category.kt @@ -14,7 +14,6 @@ import org.jetbrains.exposed.sql.andWhere import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.insertAndGetId -import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update @@ -34,7 +33,7 @@ object Category { if (name.equals(DEFAULT_CATEGORY_NAME, ignoreCase = true)) return -1 return transaction { - if (CategoryTable.select { CategoryTable.name eq name }.firstOrNull() == null) { + if (CategoryTable.selectAll().where { CategoryTable.name eq name }.firstOrNull() == null) { val newCategoryId = CategoryTable .insertAndGetId { @@ -85,7 +84,8 @@ object Category { transaction { val categories = CategoryTable - .select { + .selectAll() + .where { CategoryTable.id neq DEFAULT_CATEGORY_ID }.orderBy(CategoryTable.order to SortOrder.ASC) .toMutableList() @@ -126,7 +126,8 @@ object Category { transaction { MangaTable .leftJoin(CategoryMangaTable) - .select { MangaTable.inLibrary eq true } + .selectAll() + .where { MangaTable.inLibrary eq true } .andWhere { CategoryMangaTable.manga.isNull() } .empty() .not() @@ -153,7 +154,7 @@ object Category { fun getCategoryById(categoryId: Int): CategoryDataClass? = transaction { - CategoryTable.select { CategoryTable.id eq categoryId }.firstOrNull()?.let { + CategoryTable.selectAll().where { CategoryTable.id eq categoryId }.firstOrNull()?.let { CategoryTable.toDataClass(it) } } @@ -163,12 +164,14 @@ object Category { if (categoryId == DEFAULT_CATEGORY_ID) { MangaTable .leftJoin(CategoryMangaTable) - .select { MangaTable.inLibrary eq true } + .selectAll() + .where { MangaTable.inLibrary eq true } .andWhere { CategoryMangaTable.manga.isNull() } } else { CategoryMangaTable .leftJoin(MangaTable) - .select { CategoryMangaTable.category eq categoryId } + .selectAll() + .where { CategoryMangaTable.category eq categoryId } .andWhere { MangaTable.inLibrary eq true } }.count().toInt() } @@ -176,7 +179,8 @@ object Category { fun getCategoryMetaMap(categoryId: Int): Map = transaction { CategoryMetaTable - .select { CategoryMetaTable.ref eq categoryId } + .selectAll() + .where { CategoryMetaTable.ref eq categoryId } .associate { it[CategoryMetaTable.key] to it[CategoryMetaTable.value] } } @@ -188,7 +192,7 @@ object Category { transaction { val meta = transaction { - CategoryMetaTable.select { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) } + CategoryMetaTable.selectAll().where { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) } }.firstOrNull() if (meta == null) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/CategoryManga.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/CategoryManga.kt index 51a6a140d5..cbe6684368 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/CategoryManga.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/CategoryManga.kt @@ -17,7 +17,7 @@ import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.leftJoin import org.jetbrains.exposed.sql.max -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.wrapAsExpression import suwayomi.tachidesk.manga.impl.Category.DEFAULT_CATEGORY_ID @@ -39,7 +39,8 @@ object CategoryManga { fun notAlreadyInCategory() = CategoryMangaTable - .select { + .selectAll() + .where { (CategoryMangaTable.category eq categoryId) and (CategoryMangaTable.manga eq mangaId) }.isEmpty() @@ -71,16 +72,16 @@ object CategoryManga { val unreadCount = wrapAsExpression( ChapterTable - .slice( + .select( ChapterTable.id.count(), - ).select((ChapterTable.isRead eq false) and (ChapterTable.manga eq MangaTable.id)), + ).where { ((ChapterTable.isRead eq false) and (ChapterTable.manga eq MangaTable.id)) }, ) val downloadedCount = wrapAsExpression( ChapterTable - .slice( + .select( ChapterTable.id.count(), - ).select((ChapterTable.isDownloaded eq true) and (ChapterTable.manga eq MangaTable.id)), + ).where { ((ChapterTable.isDownloaded eq true) and (ChapterTable.manga eq MangaTable.id)) }, ) val chapterCount = ChapterTable.id.count().alias("chapter_count") @@ -104,14 +105,14 @@ object CategoryManga { MangaTable .leftJoin(ChapterTable, { MangaTable.id }, { ChapterTable.manga }) .leftJoin(CategoryMangaTable) - .slice(columns = selectedColumns) - .select { (MangaTable.inLibrary eq true) and CategoryMangaTable.category.isNull() } + .select(columns = selectedColumns) + .where { (MangaTable.inLibrary eq true) and CategoryMangaTable.category.isNull() } } else { MangaTable .innerJoin(CategoryMangaTable) .leftJoin(ChapterTable, { MangaTable.id }, { ChapterTable.manga }) - .slice(columns = selectedColumns) - .select { (MangaTable.inLibrary eq true) and (CategoryMangaTable.category eq categoryId) } + .select(columns = selectedColumns) + .where { (MangaTable.inLibrary eq true) and (CategoryMangaTable.category eq categoryId) } } // Join with the ChapterTable to fetch the last read chapter for each manga @@ -126,7 +127,8 @@ object CategoryManga { transaction { CategoryMangaTable .innerJoin(CategoryTable) - .select { + .selectAll() + .where { CategoryMangaTable.manga eq mangaId }.orderBy(CategoryTable.order to SortOrder.ASC) .map { @@ -139,7 +141,8 @@ object CategoryManga { transaction { CategoryMangaTable .innerJoin(CategoryTable) - .select { CategoryMangaTable.manga inList mangaIDs } + .selectAll() + .where { CategoryMangaTable.manga inList mangaIDs } .groupBy { it[CategoryMangaTable.manga] } .forEach { val mangaId = it.key.value diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt index 4273a30eed..c69949b040 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt @@ -12,11 +12,11 @@ import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.util.chapter.ChapterRecognition import eu.kanade.tachiyomi.util.chapter.ChapterSanitizer.sanitize +import io.github.oshai.kotlinlogging.KotlinLogging import io.github.reactivecircus.cache4k.Cache import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import kotlinx.serialization.Serializable -import mu.KotlinLogging import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.sql.Op import org.jetbrains.exposed.sql.SortOrder @@ -25,7 +25,7 @@ import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.batchInsert import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.insert -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.statements.BatchUpdateStatement import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update @@ -70,7 +70,8 @@ object Chapter { } else { transaction { ChapterTable - .select { ChapterTable.manga eq mangaId } + .selectAll() + .where { ChapterTable.manga eq mangaId } .orderBy(ChapterTable.sourceOrder to SortOrder.DESC) .map { ChapterTable.toDataClass(it) @@ -80,7 +81,14 @@ object Chapter { } } - fun getCountOfMangaChapters(mangaId: Int): Int = transaction { ChapterTable.select { ChapterTable.manga eq mangaId }.count().toInt() } + fun getCountOfMangaChapters(mangaId: Int): Int = + transaction { + ChapterTable + .selectAll() + .where { ChapterTable.manga eq mangaId } + .count() + .toInt() + } private suspend fun getSourceChapters(mangaId: Int): List { val chapterList = fetchChapterList(mangaId) @@ -88,7 +96,8 @@ object Chapter { val dbChapterMap = transaction { ChapterTable - .select { ChapterTable.manga eq mangaId } + .selectAll() + .where { ChapterTable.manga eq mangaId } .associateBy({ it[ChapterTable.url] }, { it }) } @@ -173,7 +182,8 @@ object Chapter { val chaptersInDb = transaction { ChapterTable - .select { ChapterTable.manga eq mangaId } + .selectAll() + .where { ChapterTable.manga eq mangaId } .map { ChapterTable.toDataClass(it) } .toList() } @@ -533,7 +543,8 @@ object Chapter { val mangaIds = transaction { ChapterTable - .select { condition } + .selectAll() + .where(condition) .map { it[ChapterTable.manga].value } .toSet() } @@ -544,7 +555,8 @@ object Chapter { fun getChaptersMetaMaps(chapterIds: List>): Map, Map> = transaction { ChapterMetaTable - .select { ChapterMetaTable.ref inList chapterIds } + .selectAll() + .where { ChapterMetaTable.ref inList chapterIds } .groupBy { it[ChapterMetaTable.ref] } .mapValues { it.value.associate { it[ChapterMetaTable.key] to it[ChapterMetaTable.value] } } .withDefault { emptyMap() } @@ -553,7 +565,8 @@ object Chapter { fun getChapterMetaMap(chapter: EntityID): Map = transaction { ChapterMetaTable - .select { ChapterMetaTable.ref eq chapter } + .selectAll() + .where { ChapterMetaTable.ref eq chapter } .associate { it[ChapterMetaTable.key] to it[ChapterMetaTable.value] } } @@ -566,7 +579,8 @@ object Chapter { transaction { val chapterId = ChapterTable - .select { (ChapterTable.manga eq mangaId) and (ChapterTable.sourceOrder eq chapterIndex) } + .selectAll() + .where { (ChapterTable.manga eq mangaId) and (ChapterTable.sourceOrder eq chapterIndex) } .first()[ChapterTable.id] .value modifyChapterMeta(chapterId, key, value) @@ -581,7 +595,8 @@ object Chapter { transaction { val meta = ChapterMetaTable - .select { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) } + .selectAll() + .where { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) } .firstOrNull() if (meta == null) { @@ -605,7 +620,8 @@ object Chapter { transaction { val chapterId = ChapterTable - .select { (ChapterTable.manga eq mangaId) and (ChapterTable.sourceOrder eq chapterIndex) } + .selectAll() + .where { (ChapterTable.manga eq mangaId) and (ChapterTable.sourceOrder eq chapterIndex) } .first()[ChapterTable.id] .value @@ -627,9 +643,11 @@ object Chapter { transaction { val chapterIds = ChapterTable - .slice(ChapterTable.manga, ChapterTable.id) - .select { (ChapterTable.sourceOrder inList input.chapterIndexes) and (ChapterTable.manga eq mangaId) } - .map { row -> + .select(ChapterTable.manga, ChapterTable.id) + .where { + (ChapterTable.sourceOrder inList input.chapterIndexes) and + (ChapterTable.manga eq mangaId) + }.map { row -> val chapterId = row[ChapterTable.id].value ChapterDownloadHelper.delete(mangaId, chapterId) @@ -646,8 +664,8 @@ object Chapter { fun deleteChapters(chapterIds: List) { transaction { ChapterTable - .slice(ChapterTable.manga, ChapterTable.id) - .select { ChapterTable.id inList chapterIds } + .select(ChapterTable.manga, ChapterTable.id) + .where { ChapterTable.id inList chapterIds } .forEach { row -> val chapterMangaId = row[ChapterTable.manga].value val chapterId = row[ChapterTable.id].value @@ -664,7 +682,8 @@ object Chapter { paginatedFrom(pageNum) { transaction { (ChapterTable innerJoin MangaTable) - .select { (MangaTable.inLibrary eq true) and (ChapterTable.fetchedAt greater MangaTable.inLibraryAt) } + .selectAll() + .where { (MangaTable.inLibrary eq true) and (ChapterTable.fetchedAt greater MangaTable.inLibraryAt) } .orderBy(ChapterTable.fetchedAt to SortOrder.DESC) .map { MangaChapterDataClass( diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Library.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Library.kt index 8f9e5ce472..9d5f60aa28 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Library.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Library.kt @@ -13,7 +13,7 @@ import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.launch import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.insert -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update import suwayomi.tachidesk.manga.impl.Manga.getManga @@ -31,10 +31,12 @@ object Library { transaction { val defaultCategories = CategoryTable - .select { - (CategoryTable.isDefault eq true) and (CategoryTable.id neq Category.DEFAULT_CATEGORY_ID) + .selectAll() + .where { + (CategoryTable.isDefault eq true) and + (CategoryTable.id neq Category.DEFAULT_CATEGORY_ID) }.toList() - val existingCategories = CategoryMangaTable.select { CategoryMangaTable.manga eq mangaId }.toList() + val existingCategories = CategoryMangaTable.selectAll().where { CategoryMangaTable.manga eq mangaId }.toList() MangaTable.update({ MangaTable.id eq manga.id }) { it[inLibrary] = true diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Manga.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Manga.kt index db602c9b38..5fddac09a5 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Manga.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Manga.kt @@ -15,16 +15,16 @@ import eu.kanade.tachiyomi.source.local.LocalSource import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.UpdateStrategy import eu.kanade.tachiyomi.source.online.HttpSource +import io.github.oshai.kotlinlogging.KLogger +import io.github.oshai.kotlinlogging.KotlinLogging import io.javalin.http.HttpStatus -import mu.KLogger -import mu.KotlinLogging import okhttp3.CacheControl import okhttp3.Response import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.SortOrder import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.insert -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update import suwayomi.tachidesk.manga.impl.MangaList.proxyThumbnailUrl @@ -72,14 +72,14 @@ object Manga { mangaId: Int, onlineFetch: Boolean = false, ): MangaDataClass { - var mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() } + var mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() } return if (!onlineFetch && mangaEntry[MangaTable.initialized]) { getMangaDataClass(mangaId, mangaEntry) } else { // initialize manga val sManga = fetchManga(mangaId) ?: return getMangaDataClass(mangaId, mangaEntry) - mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() } + mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() } MangaDataClass( id = mangaId, @@ -109,7 +109,7 @@ object Manga { } suspend fun fetchManga(mangaId: Int): SManga? { - val mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() } + val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() } val source = getCatalogueSourceOrNull(mangaEntry[MangaTable.sourceReference]) @@ -193,22 +193,26 @@ object Manga { return transaction { val unreadCount = ChapterTable - .select { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq false) } + .selectAll() + .where { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq false) } .count() val downloadCount = ChapterTable - .select { (ChapterTable.manga eq mangaId) and (ChapterTable.isDownloaded eq true) } + .selectAll() + .where { (ChapterTable.manga eq mangaId) and (ChapterTable.isDownloaded eq true) } .count() val chapterCount = ChapterTable - .select { (ChapterTable.manga eq mangaId) } + .selectAll() + .where { (ChapterTable.manga eq mangaId) } .count() val lastChapterRead = ChapterTable - .select { (ChapterTable.manga eq mangaId) } + .selectAll() + .where { (ChapterTable.manga eq mangaId) } .orderBy(ChapterTable.sourceOrder to SortOrder.DESC) .firstOrNull { it[ChapterTable.isRead] } @@ -252,7 +256,8 @@ object Manga { fun getMangaMetaMap(mangaId: Int): Map = transaction { MangaMetaTable - .select { MangaMetaTable.ref eq mangaId } + .selectAll() + .where { MangaMetaTable.ref eq mangaId } .associate { it[MangaMetaTable.key] to it[MangaMetaTable.value] } } @@ -264,7 +269,8 @@ object Manga { transaction { val meta = MangaMetaTable - .select { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) } + .selectAll() + .where { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) } .firstOrNull() if (meta == null) { @@ -284,7 +290,7 @@ object Manga { private suspend fun fetchThumbnailUrl(mangaId: Int): String? { getManga(mangaId, true) return transaction { - MangaTable.select { MangaTable.id eq mangaId }.first() + MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }[MangaTable.thumbnail_url] } @@ -335,7 +341,7 @@ object Manga { val cacheSaveDir = applicationDirs.tempThumbnailCacheRoot val fileName = mangaId.toString() - val mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() } + val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() } val sourceId = mangaEntry[MangaTable.sourceReference] return when (val source = getCatalogueSourceOrStub(sourceId)) { @@ -376,7 +382,7 @@ object Manga { } suspend fun getMangaThumbnail(mangaId: Int): Pair { - val mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() } + val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() } if (mangaEntry[MangaTable.inLibrary] && mangaEntry[MangaTable.sourceReference] != LocalSource.ID) { return try { @@ -399,13 +405,14 @@ object Manga { fun getLatestChapter(mangaId: Int): ChapterDataClass? = transaction { - ChapterTable.select { ChapterTable.manga eq mangaId }.maxByOrNull { it[ChapterTable.sourceOrder] } + ChapterTable.selectAll().where { ChapterTable.manga eq mangaId }.maxByOrNull { it[ChapterTable.sourceOrder] } }?.let { ChapterTable.toDataClass(it) } fun getUnreadChapters(mangaId: Int): List = transaction { ChapterTable - .select { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq false) } + .selectAll() + .where { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq false) } .orderBy(ChapterTable.sourceOrder to SortOrder.DESC) .map { ChapterTable.toDataClass(it) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/MangaList.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/MangaList.kt index 1436130a2c..6ef5ad1096 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/MangaList.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/MangaList.kt @@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.source.model.MangasPage import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.batchInsert -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.statements.BatchUpdateStatement import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.getCatalogueSourceOrStub @@ -49,8 +49,10 @@ object MangaList { transaction { val existingMangaUrlsToId = MangaTable - .select { - (MangaTable.sourceReference eq sourceId) and (MangaTable.url inList mangas.map { it.url }) + .selectAll() + .where { + (MangaTable.sourceReference eq sourceId) and + (MangaTable.url inList mangas.map { it.url }) }.associateBy { it[MangaTable.url] } val existingMangaUrls = existingMangaUrlsToId.map { it.key } @@ -123,7 +125,7 @@ object MangaList { val mangaList = transaction { val mangaIds = insertOrUpdate(sourceId) - return@transaction MangaTable.select { MangaTable.id inList mangaIds }.map { MangaTable.toDataClass(it) } + return@transaction MangaTable.selectAll().where { MangaTable.id inList mangaIds }.map { MangaTable.toDataClass(it) } } return PagedMangaListDataClass( mangaList, diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Page.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Page.kt index 343867ecf1..e3508ab6b8 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Page.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Page.kt @@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.source.online.HttpSource import kotlinx.coroutines.flow.StateFlow import org.jetbrains.exposed.sql.SortOrder import org.jetbrains.exposed.sql.and -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update import suwayomi.tachidesk.manga.impl.util.getChapterCachePath @@ -47,13 +47,15 @@ object Page { index: Int, progressFlow: ((StateFlow) -> Unit)? = null, ): Pair { - val mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() } + val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() } val source = getCatalogueSourceOrStub(mangaEntry[MangaTable.sourceReference]) val chapterEntry = transaction { ChapterTable - .select { - (ChapterTable.sourceOrder eq chapterIndex) and (ChapterTable.manga eq mangaId) + .selectAll() + .where { + (ChapterTable.sourceOrder eq chapterIndex) and + (ChapterTable.manga eq mangaId) }.first() } val chapterId = chapterEntry[ChapterTable.id].value @@ -61,7 +63,8 @@ object Page { val pageEntry = transaction { PageTable - .select { (PageTable.chapter eq chapterId) } + .selectAll() + .where { (PageTable.chapter eq chapterId) } .orderBy(PageTable.index to SortOrder.ASC) .limit(1, index.toLong()) .first() diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt index 226718ade3..916b2a61b9 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt @@ -11,12 +11,11 @@ import androidx.preference.Preference import androidx.preference.PreferenceScreen import eu.kanade.tachiyomi.source.ConfigurableSource import eu.kanade.tachiyomi.source.sourcePreferences +import io.github.oshai.kotlinlogging.KotlinLogging import io.javalin.json.JsonMapper import io.javalin.json.fromJsonString -import mu.KotlinLogging import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.insert -import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update @@ -39,7 +38,7 @@ object Source { return transaction { SourceTable.selectAll().mapNotNull { val catalogueSource = getCatalogueSourceOrNull(it[SourceTable.id].value) ?: return@mapNotNull null - val sourceExtension = ExtensionTable.select { ExtensionTable.id eq it[SourceTable.extension] }.first() + val sourceExtension = ExtensionTable.selectAll().where { ExtensionTable.id eq it[SourceTable.extension] }.first() SourceDataClass( it[SourceTable.id].value.toString(), @@ -57,9 +56,9 @@ object Source { fun getSource(sourceId: Long): SourceDataClass? { // all the data extracted fresh form the source instance return transaction { - val source = SourceTable.select { SourceTable.id eq sourceId }.firstOrNull() ?: return@transaction null + val source = SourceTable.selectAll().where { SourceTable.id eq sourceId }.firstOrNull() ?: return@transaction null val catalogueSource = getCatalogueSourceOrNull(sourceId) ?: return@transaction null - val extension = ExtensionTable.select { ExtensionTable.id eq source[SourceTable.extension] }.first() + val extension = ExtensionTable.selectAll().where { ExtensionTable.id eq source[SourceTable.extension] }.first() SourceDataClass( sourceId.toString(), @@ -160,7 +159,7 @@ object Source { transaction { val meta = transaction { - SourceMetaTable.select { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) } + SourceMetaTable.selectAll().where { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) } }.firstOrNull() if (meta == null) { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt index 59ddd3dac2..bc5d245b33 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupExport.kt @@ -10,19 +10,18 @@ package suwayomi.tachidesk.manga.impl.backup.proto import android.app.Application import android.content.Context import eu.kanade.tachiyomi.source.model.UpdateStrategy +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.combine import kotlinx.coroutines.launch -import mu.KotlinLogging import okio.Buffer import okio.Sink import okio.buffer import okio.gzip import org.jetbrains.exposed.sql.Query import org.jetbrains.exposed.sql.SortOrder -import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.manga.impl.CategoryManga @@ -175,7 +174,7 @@ object ProtoBackupExport : ProtoBackupBase() { fun createBackup(flags: BackupFlags): InputStream { // Create root object - val databaseManga = transaction { MangaTable.select { MangaTable.inLibrary eq true } } + val databaseManga = transaction { MangaTable.selectAll().where { MangaTable.inLibrary eq true } } val backup: Backup = transaction { @@ -224,7 +223,8 @@ object ProtoBackupExport : ProtoBackupBase() { val chapters = transaction { ChapterTable - .select { ChapterTable.manga eq mangaId } + .selectAll() + .where { ChapterTable.manga eq mangaId } .orderBy(ChapterTable.sourceOrder to SortOrder.DESC) .map { ChapterTable.toDataClass(it) @@ -306,7 +306,7 @@ object ProtoBackupExport : ProtoBackupBase() { .map { it[MangaTable.sourceReference] } .distinct() .map { - val sourceRow = SourceTable.select { SourceTable.id eq it }.firstOrNull() + val sourceRow = SourceTable.selectAll().where { SourceTable.id eq it }.firstOrNull() BackupSource( sourceRow?.get(SourceTable.name) ?: "", it, diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupImport.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupImport.kt index a65e880ee2..36b4b45baf 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupImport.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupImport.kt @@ -7,6 +7,7 @@ package suwayomi.tachidesk.manga.impl.backup.proto * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers @@ -17,7 +18,6 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock -import mu.KotlinLogging import okio.buffer import okio.gzip import okio.source @@ -25,7 +25,7 @@ import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.batchInsert import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.insertAndGetId -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update import suwayomi.tachidesk.graphql.types.toStatus @@ -183,7 +183,8 @@ object ProtoBackupImport : ProtoBackupBase() { backup.backupCategories.associate { val dbCategory = CategoryTable - .select { CategoryTable.name eq it.name } + .selectAll() + .where { CategoryTable.name eq it.name } .firstOrNull() val categoryId = dbCategory?.let { categoryResultRow -> @@ -275,7 +276,8 @@ object ProtoBackupImport : ProtoBackupBase() { val dbManga = transaction { MangaTable - .select { (MangaTable.url eq manga.url) and (MangaTable.sourceReference eq manga.source) } + .selectAll() + .where { (MangaTable.url eq manga.url) and (MangaTable.sourceReference eq manga.source) } .firstOrNull() } @@ -362,7 +364,7 @@ object ProtoBackupImport : ProtoBackupBase() { // merge chapter data val chaptersLength = chapters.size - val dbChapters = ChapterTable.select { ChapterTable.manga eq mangaId } + val dbChapters = ChapterTable.selectAll().where { ChapterTable.manga eq mangaId } chapters.forEach { chapter -> val dbChapter = dbChapters.find { it[ChapterTable.url] == chapter.url } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupValidator.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupValidator.kt index 113242c6fe..c2bc175366 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupValidator.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/backup/proto/ProtoBackupValidator.kt @@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore import okio.buffer import okio.gzip import okio.source -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.manga.impl.backup.proto.models.Backup import suwayomi.tachidesk.manga.impl.track.tracker.TrackerManager @@ -36,7 +36,7 @@ object ProtoBackupValidator { val missingSources = transaction { - sources.filter { SourceTable.select { SourceTable.id eq it.key }.firstOrNull() == null } + sources.filter { SourceTable.selectAll().where { SourceTable.id eq it.key }.firstOrNull() == null } } val trackers = diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt index bc029d559a..ea7e47e36b 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/chapter/ChapterForDownload.kt @@ -9,14 +9,14 @@ package suwayomi.tachidesk.manga.impl.chapter import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter -import mu.KLogger -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KLogger +import io.github.oshai.kotlinlogging.KotlinLogging import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.batchInsert import org.jetbrains.exposed.sql.deleteWhere -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update import suwayomi.tachidesk.manga.impl.ChapterDownloadHelper @@ -98,7 +98,8 @@ private class ChapterForDownload( optMangaId: Int? = null, ) = transaction { ChapterTable - .select { + .selectAll() + .where { if (optChapterId != null) { ChapterTable.id eq optChapterId } else if (optChapterIndex != null && optMangaId != null) { @@ -110,7 +111,7 @@ private class ChapterForDownload( } private suspend fun fetchPageList(): List { - val mangaEntry = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() } + val mangaEntry = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() } val source = getCatalogueSourceOrStub(mangaEntry[MangaTable.sourceReference]) return source.getPageList( diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt index 38a676c2c7..a9b00b848f 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/DownloadManager.kt @@ -9,6 +9,7 @@ package suwayomi.tachidesk.manga.impl.download import android.app.Application import android.content.Context +import io.github.oshai.kotlinlogging.KotlinLogging import io.javalin.websocket.WsContext import io.javalin.websocket.WsMessageContext import kotlinx.coroutines.CoroutineScope @@ -26,9 +27,8 @@ import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.sample import kotlinx.coroutines.launch import kotlinx.serialization.Serializable -import mu.KotlinLogging import org.jetbrains.exposed.sql.and -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.manga.impl.download.model.DownloadChapter import suwayomi.tachidesk.manga.impl.download.model.DownloadState.Downloading @@ -284,8 +284,8 @@ object DownloadManager { val chapter = transaction { ChapterTable - .slice(ChapterTable.id) - .select { ChapterTable.manga.eq(mangaId) and ChapterTable.sourceOrder.eq(chapterIndex) } + .select(ChapterTable.id) + .where { ChapterTable.manga.eq(mangaId) and ChapterTable.sourceOrder.eq(chapterIndex) } .first() } enqueue(EnqueueInput(chapterIds = listOf(chapter[ChapterTable.id].value))) @@ -304,7 +304,8 @@ object DownloadManager { val chapters = transaction { (ChapterTable innerJoin MangaTable) - .select { ChapterTable.id inList input.chapterIds } + .selectAll() + .where { ChapterTable.id inList input.chapterIds } .orderBy(ChapterTable.manga) .orderBy(ChapterTable.sourceOrder) .toList() diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/Downloader.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/Downloader.kt index a30ffc8557..3578d7d2ed 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/Downloader.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/Downloader.kt @@ -7,6 +7,8 @@ package suwayomi.tachidesk.manga.impl.download * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +import io.github.oshai.kotlinlogging.KLogger +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job @@ -15,8 +17,6 @@ import kotlinx.coroutines.currentCoroutineContext import kotlinx.coroutines.ensureActive import kotlinx.coroutines.isActive import kotlinx.coroutines.launch -import mu.KLogger -import mu.KotlinLogging import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/fileProvider/ChaptersFilesProvider.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/fileProvider/ChaptersFilesProvider.kt index 73c8e2ca03..18c234563a 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/fileProvider/ChaptersFilesProvider.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/download/fileProvider/ChaptersFilesProvider.kt @@ -9,7 +9,7 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.sample import org.apache.commons.compress.archivers.zip.ZipArchiveEntry -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.manga.impl.Page import suwayomi.tachidesk.manga.impl.download.model.DownloadChapter @@ -141,10 +141,10 @@ abstract class ChaptersFilesProvider( createComicInfoFile( downloadCacheFolder.toPath(), transaction { - MangaTable.select { MangaTable.id eq mangaId }.first() + MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() }, transaction { - ChapterTable.select { ChapterTable.id eq chapterId }.first() + ChapterTable.selectAll().where { ChapterTable.id eq chapterId }.first() }, ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt index cf54365054..059f789810 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt @@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.SourceFactory -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import okhttp3.CacheControl import okio.buffer import okio.sink @@ -21,7 +21,7 @@ import okio.source import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.insert -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update import suwayomi.tachidesk.manga.impl.extension.ExtensionsList.extensionTableAsDataClass @@ -101,7 +101,7 @@ object Extension { // if it's installed and we want to update, it first has to be uninstalled val isInstalled = transaction { - ExtensionTable.select { ExtensionTable.apkName eq apkName }.firstOrNull() + ExtensionTable.selectAll().where { ExtensionTable.apkName eq apkName }.firstOrNull() }?.get(ExtensionTable.isInstalled) ?: false val fileNameWithoutType = apkName.substringBefore(".apk") @@ -177,7 +177,7 @@ object Extension { // update extension info transaction { - if (ExtensionTable.select { ExtensionTable.pkgName eq pkgName }.firstOrNull() == null) { + if (ExtensionTable.selectAll().where { ExtensionTable.pkgName eq pkgName }.firstOrNull() == null) { ExtensionTable.insert { it[this.apkName] = apkName it[name] = extensionName @@ -198,7 +198,11 @@ object Extension { } val extensionId = - ExtensionTable.select { ExtensionTable.pkgName eq pkgName }.first()[ExtensionTable.id].value + ExtensionTable + .selectAll() + .where { ExtensionTable.pkgName eq pkgName } + .first()[ExtensionTable.id] + .value sources.forEach { httpSource -> SourceTable.insert { @@ -293,14 +297,14 @@ object Extension { fun uninstallExtension(pkgName: String) { logger.debug("Uninstalling $pkgName") - val extensionRecord = transaction { ExtensionTable.select { ExtensionTable.pkgName eq pkgName }.first() } + val extensionRecord = transaction { ExtensionTable.selectAll().where { ExtensionTable.pkgName eq pkgName }.first() } val fileNameWithoutType = extensionRecord[ExtensionTable.apkName].substringBefore(".apk") val jarPath = "${applicationDirs.extensionsRoot}/$fileNameWithoutType.jar" val sources = transaction { val extensionId = extensionRecord[ExtensionTable.id].value - val sources = SourceTable.select { SourceTable.extension eq extensionId }.map { it[SourceTable.id].value } + val sources = SourceTable.selectAll().where { SourceTable.extension eq extensionId }.map { it[SourceTable.id].value } SourceTable.deleteWhere { SourceTable.extension eq extensionId } @@ -349,7 +353,7 @@ object Extension { if (apkName == "localSource") { "" } else { - transaction { ExtensionTable.select { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl] + transaction { ExtensionTable.selectAll().where { ExtensionTable.apkName eq apkName }.first() }[ExtensionTable.iconUrl] } val cacheSaveDir = "${applicationDirs.extensionsRoot}/icon" diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt index 187644be40..3bc6f11014 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt @@ -8,9 +8,9 @@ package suwayomi.tachidesk.manga.impl.extension * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import eu.kanade.tachiyomi.source.local.LocalSource +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock -import mu.KotlinLogging import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.SqlExpressionBuilder.inList diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/github/ExtensionGithubApi.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/github/ExtensionGithubApi.kt index 9b6642d6db..7da708a1f5 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/github/ExtensionGithubApi.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/github/ExtensionGithubApi.kt @@ -11,9 +11,9 @@ import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.awaitSuccess import eu.kanade.tachiyomi.network.parseAs +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json -import mu.KotlinLogging import suwayomi.tachidesk.manga.impl.util.PackageTools.LIB_VERSION_MAX import suwayomi.tachidesk.manga.impl.util.PackageTools.LIB_VERSION_MIN import uy.kohesive.injekt.injectLazy diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/Track.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/Track.kt index ddf4ef57ff..b0d65452d0 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/Track.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/Track.kt @@ -1,18 +1,18 @@ package suwayomi.tachidesk.manga.impl.track +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.launch import kotlinx.serialization.Serializable -import mu.KotlinLogging import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.SortOrder import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.insertAndGetId -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.update import suwayomi.tachidesk.manga.impl.track.tracker.DeletableTrackService @@ -75,7 +75,8 @@ object Track { val recordMap = transaction { TrackRecordTable - .select { TrackRecordTable.mangaId eq mangaId } + .selectAll() + .where { TrackRecordTable.mangaId eq mangaId } .map { it.toTrackRecordDataClass() } }.associateBy { it.trackerId } @@ -138,7 +139,8 @@ object Track { val track = transaction { TrackSearchTable - .select { + .selectAll() + .where { TrackSearchTable.trackerId eq trackerId and (TrackSearchTable.remoteId eq remoteId) }.first() @@ -162,7 +164,8 @@ object Track { val oldestChapter = transaction { ChapterTable - .select { + .selectAll() + .where { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq true) }.orderBy(ChapterTable.lastReadAt to SortOrder.ASC) .limit(1) @@ -186,7 +189,7 @@ object Track { suspend fun refresh(recordId: Int) { val recordDb = transaction { - TrackRecordTable.select { TrackRecordTable.id eq recordId }.first() + TrackRecordTable.selectAll().where { TrackRecordTable.id eq recordId }.first() } val tracker = TrackerManager.getTracker(recordDb[TrackRecordTable.trackerId])!! @@ -202,7 +205,7 @@ object Track { ) { val recordDb = transaction { - TrackRecordTable.select { TrackRecordTable.id eq recordId }.first() + TrackRecordTable.selectAll().where { TrackRecordTable.id eq recordId }.first() } val tracker = TrackerManager.getTracker(recordDb[TrackRecordTable.trackerId]) @@ -223,7 +226,7 @@ object Track { } val recordDb = transaction { - TrackRecordTable.select { TrackRecordTable.id eq input.recordId }.first() + TrackRecordTable.selectAll().where { TrackRecordTable.id eq input.recordId }.first() } val tracker = TrackerManager.getTracker(recordDb[TrackRecordTable.trackerId])!! @@ -294,7 +297,8 @@ object Track { private fun queryMaxReadChapter(mangaId: Int): ResultRow? = transaction { ChapterTable - .select { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq true) } + .selectAll() + .where { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq true) } .orderBy(ChapterTable.chapter_number to SortOrder.DESC) .limit(1) .firstOrNull() @@ -307,7 +311,8 @@ object Track { val records = transaction { TrackRecordTable - .select { TrackRecordTable.mangaId eq mangaId } + .selectAll() + .where { TrackRecordTable.mangaId eq mangaId } .toList() } @@ -365,7 +370,8 @@ object Track { transaction { val existingRecord = TrackRecordTable - .select { + .selectAll() + .where { (TrackRecordTable.mangaId eq track.manga_id) and (TrackRecordTable.trackerId eq track.sync_id) }.singleOrNull() diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/TrackerPreferences.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/TrackerPreferences.kt index 70ddf88665..1fc9f8730a 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/TrackerPreferences.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/TrackerPreferences.kt @@ -2,7 +2,7 @@ package suwayomi.tachidesk.manga.impl.track.tracker import android.app.Application import android.content.Context -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import suwayomi.tachidesk.manga.impl.track.tracker.anilist.Anilist import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/anilist/Anilist.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/anilist/Anilist.kt index 74fac8ed4a..c219d17a59 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/anilist/Anilist.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/anilist/Anilist.kt @@ -1,9 +1,9 @@ package suwayomi.tachidesk.manga.impl.track.tracker.anilist import android.annotation.StringRes +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import mu.KotlinLogging import suwayomi.tachidesk.manga.impl.track.tracker.DeletableTrackService import suwayomi.tachidesk.manga.impl.track.tracker.Tracker import suwayomi.tachidesk.manga.impl.track.tracker.extractToken diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/myanimelist/MyAnimeList.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/myanimelist/MyAnimeList.kt index 4faea7cc56..3ae96b927c 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/myanimelist/MyAnimeList.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/tracker/myanimelist/MyAnimeList.kt @@ -1,9 +1,9 @@ package suwayomi.tachidesk.manga.impl.track.tracker.myanimelist import android.annotation.StringRes +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import mu.KotlinLogging import suwayomi.tachidesk.manga.impl.track.tracker.DeletableTrackService import suwayomi.tachidesk.manga.impl.track.tracker.Tracker import suwayomi.tachidesk.manga.impl.track.tracker.extractToken diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/Updater.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/Updater.kt index 8e594c3e40..af220b5b37 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/Updater.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/Updater.kt @@ -3,6 +3,7 @@ package suwayomi.tachidesk.manga.impl.update import android.app.Application import android.content.Context import eu.kanade.tachiyomi.source.model.UpdateStrategy +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DelicateCoroutinesApi @@ -27,7 +28,6 @@ import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Semaphore import kotlinx.coroutines.sync.withPermit -import mu.KotlinLogging import suwayomi.tachidesk.manga.impl.Category import suwayomi.tachidesk.manga.impl.CategoryManga import suwayomi.tachidesk.manga.impl.Chapter diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/UpdaterSocket.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/UpdaterSocket.kt index ca333f4a22..905c9d6200 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/UpdaterSocket.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/update/UpdaterSocket.kt @@ -1,5 +1,6 @@ package suwayomi.tachidesk.manga.impl.update +import io.github.oshai.kotlinlogging.KotlinLogging import io.javalin.websocket.WsContext import io.javalin.websocket.WsMessageContext import kotlinx.coroutines.CoroutineScope @@ -8,7 +9,6 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import mu.KotlinLogging import uy.kohesive.injekt.injectLazy object UpdaterSocket : Websocket() { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/BytecodeEditor.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/BytecodeEditor.kt index 0006939e65..2a64ae0cd7 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/BytecodeEditor.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/BytecodeEditor.kt @@ -7,7 +7,7 @@ package suwayomi.tachidesk.manga.impl.util * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.objectweb.asm.ClassReader import org.objectweb.asm.ClassVisitor import org.objectweb.asm.ClassWriter diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/DirName.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/DirName.kt index 55a10b0298..f8612edd82 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/DirName.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/DirName.kt @@ -8,7 +8,7 @@ package suwayomi.tachidesk.manga.impl.util * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import org.jetbrains.exposed.sql.ResultRow -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource import suwayomi.tachidesk.manga.model.table.ChapterTable @@ -33,7 +33,7 @@ private fun getChapterDir( mangaId: Int, chapterId: Int, ): String { - val chapterEntry = transaction { ChapterTable.select { ChapterTable.id eq chapterId }.first() } + val chapterEntry = transaction { ChapterTable.selectAll().where { ChapterTable.id eq chapterId }.first() } val chapterDir = SafePath.buildValidFilename( @@ -91,4 +91,4 @@ fun updateMangaDownloadDir( } } -private fun getMangaEntry(mangaId: Int): ResultRow = transaction { MangaTable.select { MangaTable.id eq mangaId }.first() } +private fun getMangaEntry(mangaId: Int): ResultRow = transaction { MangaTable.selectAll().where { MangaTable.id eq mangaId }.first() } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/GetComicInfo.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/GetComicInfo.kt index 5633b2100e..ce29925ec6 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/GetComicInfo.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/GetComicInfo.kt @@ -6,7 +6,7 @@ import eu.kanade.tachiyomi.source.local.metadata.ComicInfoPublishingStatus import nl.adaptivity.xmlutil.serialization.XML import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.SortOrder -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.manga.model.table.CategoryMangaTable import suwayomi.tachidesk.manga.model.table.CategoryTable @@ -77,7 +77,8 @@ fun createComicInfoFile( transaction { CategoryMangaTable .innerJoin(CategoryTable) - .select { + .selectAll() + .where { CategoryMangaTable.manga eq manga[MangaTable.id] }.orderBy(CategoryTable.order to SortOrder.ASC) .map { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/PackageTools.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/PackageTools.kt index 9b09457307..37609e1660 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/PackageTools.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/PackageTools.kt @@ -14,7 +14,7 @@ import com.googlecode.d2j.dex.Dex2jar import com.googlecode.d2j.reader.MultiDexFileReader import com.googlecode.dex2jar.tools.BaksmaliBaseDexExceptionHandler import eu.kanade.tachiyomi.util.lang.Hash -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import net.dongliu.apk.parser.ApkFile import net.dongliu.apk.parser.ApkParsers import org.w3c.dom.Element diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/source/GetCatalogueSource.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/source/GetCatalogueSource.kt index 6fe212bea2..e6f88ed3c7 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/source/GetCatalogueSource.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/util/source/GetCatalogueSource.kt @@ -11,8 +11,8 @@ import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.SourceFactory import eu.kanade.tachiyomi.source.online.HttpSource -import mu.KotlinLogging -import org.jetbrains.exposed.sql.select +import io.github.oshai.kotlinlogging.KotlinLogging +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.manga.impl.util.PackageTools.loadExtensionSources import suwayomi.tachidesk.manga.model.table.ExtensionTable @@ -35,13 +35,13 @@ object GetCatalogueSource { val sourceRecord = transaction { - SourceTable.select { SourceTable.id eq sourceId }.firstOrNull() + SourceTable.selectAll().where { SourceTable.id eq sourceId }.firstOrNull() } ?: return null val extensionId = sourceRecord[SourceTable.extension] val extensionRecord = transaction { - ExtensionTable.select { ExtensionTable.id eq extensionId }.first() + ExtensionTable.selectAll().where { ExtensionTable.id eq extensionId }.first() } val apkName = extensionRecord[ExtensionTable.apkName] diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/ChapterTable.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/ChapterTable.kt index f3abc528b8..03d443ef08 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/ChapterTable.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/ChapterTable.kt @@ -10,7 +10,7 @@ package suwayomi.tachidesk.manga.model.table import org.jetbrains.exposed.dao.id.IntIdTable import org.jetbrains.exposed.sql.ReferenceOption import org.jetbrains.exposed.sql.ResultRow -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.manga.impl.Chapter.getChapterMetaMap import suwayomi.tachidesk.manga.model.dataclass.ChapterDataClass @@ -59,6 +59,13 @@ fun ChapterTable.toDataClass(chapterEntry: ResultRow) = realUrl = chapterEntry[realUrl], downloaded = chapterEntry[isDownloaded], pageCount = chapterEntry[pageCount], - chapterCount = transaction { ChapterTable.select { manga eq chapterEntry[manga].value }.count().toInt() }, + chapterCount = + transaction { + ChapterTable + .selectAll() + .where { manga eq chapterEntry[manga].value } + .count() + .toInt() + }, meta = getChapterMetaMap(chapterEntry[id]), ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/TrackSearchTable.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/TrackSearchTable.kt index 29f4dcd299..660a9c864f 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/TrackSearchTable.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/model/table/TrackSearchTable.kt @@ -12,7 +12,7 @@ import org.jetbrains.exposed.dao.id.IntIdTable import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.batchInsert -import org.jetbrains.exposed.sql.select +import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.statements.BatchUpdateStatement import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.manga.impl.track.tracker.model.TrackSearch @@ -38,8 +38,10 @@ fun List.insertAll(): List { val existing = transaction { TrackSearchTable - .select { - TrackSearchTable.trackerId inList trackerIds and (TrackSearchTable.remoteId inList remoteIds) + .selectAll() + .where { + TrackSearchTable.trackerId inList trackerIds and + (TrackSearchTable.remoteId inList remoteIds) }.toList() } @@ -95,7 +97,7 @@ fun List.insertAll(): List { toUpdate ?.mapNotNull { it.first } ?.let { ids -> - transaction { TrackSearchTable.select { TrackSearchTable.id inList ids }.toList() } + transaction { TrackSearchTable.selectAll().where { TrackSearchTable.id inList ids }.toList() } }.orEmpty() (insertedRows + updatedRows) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/JavalinSetup.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/JavalinSetup.kt index 8945cab5b6..03469ccfef 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/JavalinSetup.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/JavalinSetup.kt @@ -7,6 +7,7 @@ package suwayomi.tachidesk.server * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +import io.github.oshai.kotlinlogging.KotlinLogging import io.javalin.Javalin import io.javalin.apibuilder.ApiBuilder.path import io.javalin.http.UnauthorizedResponse @@ -17,7 +18,6 @@ import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.flow.combine import kotlinx.coroutines.future.future import kotlinx.coroutines.runBlocking -import mu.KotlinLogging import org.eclipse.jetty.server.ServerConnector import suwayomi.tachidesk.global.GlobalAPI import suwayomi.tachidesk.graphql.GraphQL diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/Migration.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/Migration.kt index b83ce281b8..19253c1ad5 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/Migration.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/Migration.kt @@ -2,7 +2,7 @@ package suwayomi.tachidesk.server import android.app.Application import android.content.Context -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.io.File diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt index 73f4785be2..15fffc8ef1 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/ServerSetup.kt @@ -13,12 +13,12 @@ import eu.kanade.tachiyomi.App import eu.kanade.tachiyomi.createAppModule import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.source.local.LocalSource +import io.github.oshai.kotlinlogging.KotlinLogging import io.javalin.json.JavalinJackson import io.javalin.json.JsonMapper import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged -import mu.KotlinLogging import org.bouncycastle.jce.provider.BouncyCastleProvider import org.koin.core.context.startKoin import org.koin.core.module.Module diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/database/DBManager.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/database/DBManager.kt index db4801c721..ba616d93d0 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/database/DBManager.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/database/DBManager.kt @@ -9,9 +9,10 @@ package suwayomi.tachidesk.server.database import de.neonew.exposed.migrations.loadMigrationsFrom import de.neonew.exposed.migrations.runMigrations -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.DatabaseConfig +import org.jetbrains.exposed.sql.ExperimentalKeywordApi import suwayomi.tachidesk.server.ApplicationDirs import suwayomi.tachidesk.server.ServerConfig import uy.kohesive.injekt.Injekt @@ -26,6 +27,8 @@ object DBManager { databaseConfig = DatabaseConfig { useNestedTransactions = true + @OptIn(ExperimentalKeywordApi::class) + preserveKeywordCasing = false }, ) } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/util/AppExit.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/util/AppExit.kt index 2f2d10a9fb..7f683396c7 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/util/AppExit.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/util/AppExit.kt @@ -7,7 +7,7 @@ package suwayomi.tachidesk.server.util * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import kotlin.system.exitProcess private val logger = KotlinLogging.logger {} diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/util/AppMutex.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/util/AppMutex.kt index aa7eff3e3d..7533a29c25 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/util/AppMutex.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/util/AppMutex.kt @@ -7,9 +7,9 @@ package suwayomi.tachidesk.server.util * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +import io.github.oshai.kotlinlogging.KotlinLogging import io.javalin.json.JsonMapper import io.javalin.json.fromJsonString -import mu.KotlinLogging import okhttp3.OkHttpClient import okhttp3.Request.Builder import suwayomi.tachidesk.global.impl.AboutDataClass diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/util/Browser.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/util/Browser.kt index 9f9d7d4522..5fbf70a8ac 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/util/Browser.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/util/Browser.kt @@ -8,7 +8,7 @@ package suwayomi.tachidesk.server.util * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import dorkbox.desktop.Desktop -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import suwayomi.tachidesk.server.serverConfig object Browser { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/util/SystemTray.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/util/SystemTray.kt index 3c96722376..6c48b40b52 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/util/SystemTray.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/util/SystemTray.kt @@ -10,7 +10,7 @@ package suwayomi.tachidesk.server.util import dorkbox.systemTray.MenuItem import dorkbox.systemTray.SystemTray import dorkbox.util.CacheUtil -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import suwayomi.tachidesk.server.ServerConfig import suwayomi.tachidesk.server.generated.BuildConfig import suwayomi.tachidesk.server.serverConfig diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt index 5e2d6d8db4..75282fff0c 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/util/WebInterfaceManager.kt @@ -12,6 +12,8 @@ import android.content.Context import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.awaitSuccess +import io.github.oshai.kotlinlogging.KLogger +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers @@ -32,8 +34,6 @@ import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.jsonArray import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive -import mu.KLogger -import mu.KotlinLogging import net.lingala.zip4j.ZipFile import suwayomi.tachidesk.graphql.types.AboutWebUI import suwayomi.tachidesk.graphql.types.UpdateState diff --git a/server/src/main/kotlin/suwayomi/tachidesk/util/HAScheduler.kt b/server/src/main/kotlin/suwayomi/tachidesk/util/HAScheduler.kt index 060016042b..5d09faf98f 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/util/HAScheduler.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/util/HAScheduler.kt @@ -5,10 +5,10 @@ import com.cronutils.model.CronType.CRON4J import com.cronutils.model.definition.CronDefinitionBuilder import com.cronutils.model.time.ExecutionTime import com.cronutils.parser.CronParser +import io.github.oshai.kotlinlogging.KotlinLogging import it.sauronsoftware.cron4j.Scheduler import it.sauronsoftware.cron4j.Task import it.sauronsoftware.cron4j.TaskExecutionContext -import mu.KotlinLogging import java.time.ZonedDateTime import java.util.Date import java.util.PriorityQueue diff --git a/server/src/test/kotlin/masstest/CloudFlareTest.kt b/server/src/test/kotlin/masstest/CloudFlareTest.kt index e3d0186357..3a02bfc0af 100644 --- a/server/src/test/kotlin/masstest/CloudFlareTest.kt +++ b/server/src/test/kotlin/masstest/CloudFlareTest.kt @@ -1,9 +1,9 @@ package masstest import eu.kanade.tachiyomi.source.online.HttpSource +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.runBlocking import kotlinx.coroutines.test.runTest -import mu.KotlinLogging import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance diff --git a/server/src/test/kotlin/masstest/TestExtensionCompatibility.kt b/server/src/test/kotlin/masstest/TestExtensionCompatibility.kt index 5a09e1d0a9..ab0e5f8a95 100644 --- a/server/src/test/kotlin/masstest/TestExtensionCompatibility.kt +++ b/server/src/test/kotlin/masstest/TestExtensionCompatibility.kt @@ -10,13 +10,13 @@ package masstest import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.HttpSource +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.runBlocking import kotlinx.coroutines.sync.Semaphore import kotlinx.coroutines.sync.withPermit -import mu.KotlinLogging import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance diff --git a/server/src/test/kotlin/suwayomi/tachidesk/test/ApplicationTest.kt b/server/src/test/kotlin/suwayomi/tachidesk/test/ApplicationTest.kt index 9c4cc5bec9..7c8b91070a 100644 --- a/server/src/test/kotlin/suwayomi/tachidesk/test/ApplicationTest.kt +++ b/server/src/test/kotlin/suwayomi/tachidesk/test/ApplicationTest.kt @@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.App import eu.kanade.tachiyomi.createAppModule import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.source.local.LocalSource -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.jetbrains.exposed.sql.Database import org.junit.jupiter.api.BeforeAll import org.koin.core.context.startKoin diff --git a/server/src/test/kotlin/suwayomi/tachidesk/test/TestUtils.kt b/server/src/test/kotlin/suwayomi/tachidesk/test/TestUtils.kt index ca10798672..8bd8e16370 100644 --- a/server/src/test/kotlin/suwayomi/tachidesk/test/TestUtils.kt +++ b/server/src/test/kotlin/suwayomi/tachidesk/test/TestUtils.kt @@ -9,7 +9,7 @@ package suwayomi.tachidesk.test import ch.qos.logback.classic.Level import eu.kanade.tachiyomi.source.model.SManga -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.jetbrains.exposed.dao.id.IdTable import org.jetbrains.exposed.sql.batchInsert import org.jetbrains.exposed.sql.deleteAll