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

* Update to exposed-migrations v3.5.0

* Update to kotlin-logging v7.0.0

* Update to exposed v0.46.0

* Update to exposed v0.47.0

* Update to exposed v0.55.0

* Update to exposed v0.56.0

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

View File

@@ -14,9 +14,9 @@ import com.typesafe.config.ConfigValue
import com.typesafe.config.ConfigValueFactory import com.typesafe.config.ConfigValueFactory
import com.typesafe.config.parser.ConfigDocument import com.typesafe.config.parser.ConfigDocument
import com.typesafe.config.parser.ConfigDocumentFactory import com.typesafe.config.parser.ConfigDocumentFactory
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.sync.withLock
import mu.KotlinLogging
import java.io.File import java.io.File
/** /**

View File

@@ -15,7 +15,8 @@ import ch.qos.logback.core.rolling.RollingFileAppender
import ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy import ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy
import ch.qos.logback.core.util.FileSize import ch.qos.logback.core.util.FileSize
import com.typesafe.config.Config 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.Logger
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
@@ -73,7 +74,7 @@ private fun createRollingFileAppender(
} }
private fun getBaseLogger(): ch.qos.logback.classic.Logger = 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 { private fun getLogger(name: String): ch.qos.logback.classic.Logger {
val context = LoggerFactory.getILoggerFactory() as LoggerContext val context = LoggerFactory.getILoggerFactory() as LoggerContext

View File

@@ -14,11 +14,11 @@ import com.russhwolf.settings.Settings
import com.russhwolf.settings.serialization.decodeValue import com.russhwolf.settings.serialization.decodeValue
import com.russhwolf.settings.serialization.decodeValueOrNull import com.russhwolf.settings.serialization.decodeValueOrNull
import com.russhwolf.settings.serialization.encodeValue import com.russhwolf.settings.serialization.encodeValue
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.SerializationException import kotlinx.serialization.SerializationException
import kotlinx.serialization.builtins.SetSerializer import kotlinx.serialization.builtins.SetSerializer
import kotlinx.serialization.builtins.serializer import kotlinx.serialization.builtins.serializer
import mu.KotlinLogging
import xyz.nulldev.androidcompat.util.SafePath import xyz.nulldev.androidcompat.util.SafePath
import xyz.nulldev.ts.config.ApplicationRootDir import xyz.nulldev.ts.config.ApplicationRootDir
import java.util.Properties import java.util.Properties

View File

@@ -3,7 +3,7 @@ package xyz.nulldev.androidcompat.service
import android.app.Service import android.app.Service
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import mu.KotlinLogging import io.github.oshai.kotlinlogging.KotlinLogging
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
import kotlin.concurrent.thread import kotlin.concurrent.thread

View File

@@ -5,7 +5,7 @@ serialization = "1.7.3"
okhttp = "5.0.0-alpha.14" # Major version is locked by Tachiyomi extensions okhttp = "5.0.0-alpha.14" # Major version is locked by Tachiyomi extensions
javalin = "6.3.0" javalin = "6.3.0"
jackson = "2.18.2" # jackson version locked by javalin, ref: `io.javalin.core.util.OptionalDependency` 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 dex2jar = "v64" # Stuck until https://github.com/ThexXTURBOXx/dex2jar/issues/27 is fixed
polyglot = "24.1.1" polyglot = "24.1.1"
settings = "1.3.0" settings = "1.3.0"
@@ -36,7 +36,7 @@ serialization-xml = { module = "io.github.pdvrieze.xmlutil:serialization-jvm", v
# Logging # Logging
slf4japi = "org.slf4j:slf4j-api:2.0.16" slf4japi = "org.slf4j:slf4j-api:2.0.16"
logback = "ch.qos.logback:logback-classic:1.5.12" 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
okhttp-core = { module = "com.squareup.okhttp3:okhttp", version.ref = "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 h2 = "com.h2database:h2:1.4.200" # current database driver, can't update to h2 v2 without sql migration
# Exposed Migrations # Exposed Migrations
exposed-migrations = "com.github.Suwayomi:exposed-migrations:3.2.0" exposed-migrations = "com.github.Suwayomi:exposed-migrations:3.5.0"
# Dependency Injection # Dependency Injection
koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" } koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }

View File

@@ -12,13 +12,13 @@ import eu.kanade.tachiyomi.network.interceptor.CloudflareInterceptor
import eu.kanade.tachiyomi.network.interceptor.IgnoreGzipInterceptor import eu.kanade.tachiyomi.network.interceptor.IgnoreGzipInterceptor
import eu.kanade.tachiyomi.network.interceptor.UncaughtExceptionInterceptor import eu.kanade.tachiyomi.network.interceptor.UncaughtExceptionInterceptor
import eu.kanade.tachiyomi.network.interceptor.UserAgentInterceptor import eu.kanade.tachiyomi.network.interceptor.UserAgentInterceptor
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.drop import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import mu.KotlinLogging
import okhttp3.Cache import okhttp3.Cache
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.brotli.BrotliInterceptor import okhttp3.brotli.BrotliInterceptor

View File

@@ -4,6 +4,7 @@ import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.POST
import eu.kanade.tachiyomi.network.awaitSuccess import eu.kanade.tachiyomi.network.awaitSuccess
import eu.kanade.tachiyomi.network.parseAs import eu.kanade.tachiyomi.network.parseAs
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
@@ -15,7 +16,6 @@ import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import mu.KotlinLogging
import okhttp3.Cookie import okhttp3.Cookie
import okhttp3.HttpUrl import okhttp3.HttpUrl
import okhttp3.Interceptor import okhttp3.Interceptor

View File

@@ -26,19 +26,19 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.util.chapter.ChapterRecognition import eu.kanade.tachiyomi.util.chapter.ChapterRecognition
import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder
import eu.kanade.tachiyomi.util.storage.EpubFile import eu.kanade.tachiyomi.util.storage.EpubFile
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import kotlinx.serialization.json.decodeFromStream import kotlinx.serialization.json.decodeFromStream
import mu.KotlinLogging
import nl.adaptivity.xmlutil.ExperimentalXmlUtilApi import nl.adaptivity.xmlutil.ExperimentalXmlUtilApi
import nl.adaptivity.xmlutil.core.KtXmlReader import nl.adaptivity.xmlutil.core.KtXmlReader
import nl.adaptivity.xmlutil.serialization.XML import nl.adaptivity.xmlutil.serialization.XML
import org.apache.commons.compress.archivers.zip.ZipFile import org.apache.commons.compress.archivers.zip.ZipFile
import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.insertAndGetId 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.transactions.transaction
import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.registerCatalogueSource import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.registerCatalogueSource
import suwayomi.tachidesk.manga.impl.util.storage.ImageUtil import suwayomi.tachidesk.manga.impl.util.storage.ImageUtil
@@ -444,7 +444,7 @@ class LocalSource(
fun register() { fun register() {
transaction { transaction {
val sourceRecord = SourceTable.select { SourceTable.id eq ID }.firstOrNull() val sourceRecord = SourceTable.selectAll().where { SourceTable.id eq ID }.firstOrNull()
if (sourceRecord == null) { if (sourceRecord == null) {
// must do this to avoid database integrity errors // must do this to avoid database integrity errors

View File

@@ -1,7 +1,6 @@
package suwayomi.tachidesk.global.impl package suwayomi.tachidesk.global.impl
import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update
@@ -22,7 +21,7 @@ object GlobalMeta {
transaction { transaction {
val meta = val meta =
transaction { transaction {
GlobalMetaTable.select { GlobalMetaTable.key eq key } GlobalMetaTable.selectAll().where { GlobalMetaTable.key eq key }
}.firstOrNull() }.firstOrNull()
if (meta == null) { if (meta == null) {

View File

@@ -2,7 +2,7 @@ package suwayomi.tachidesk.graphql
import com.expediagroup.graphql.server.extensions.toGraphQLError import com.expediagroup.graphql.server.extensions.toGraphQLError
import graphql.execution.DataFetcherResult import graphql.execution.DataFetcherResult
import mu.KotlinLogging import io.github.oshai.kotlinlogging.KotlinLogging
val logger = KotlinLogging.logger { } val logger = KotlinLogging.logger { }

View File

@@ -13,7 +13,7 @@ import org.dataloader.DataLoader
import org.dataloader.DataLoaderFactory import org.dataloader.DataLoaderFactory
import org.jetbrains.exposed.sql.Slf4jSqlDebugLogger import org.jetbrains.exposed.sql.Slf4jSqlDebugLogger
import org.jetbrains.exposed.sql.addLogger 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 org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.types.CategoryNodeList import suwayomi.tachidesk.graphql.types.CategoryNodeList
import suwayomi.tachidesk.graphql.types.CategoryNodeList.Companion.toNodeList import suwayomi.tachidesk.graphql.types.CategoryNodeList.Companion.toNodeList
@@ -32,7 +32,8 @@ class CategoryDataLoader : KotlinDataLoader<Int, CategoryType> {
addLogger(Slf4jSqlDebugLogger) addLogger(Slf4jSqlDebugLogger)
val categories = val categories =
CategoryTable CategoryTable
.select { CategoryTable.id inList ids } .selectAll()
.where { CategoryTable.id inList ids }
.map { CategoryType(it) } .map { CategoryType(it) }
.associateBy { it.id } .associateBy { it.id }
ids.map { categories[it] } ids.map { categories[it] }
@@ -50,7 +51,7 @@ class CategoryForIdsDataLoader : KotlinDataLoader<List<Int>, CategoryNodeList> {
transaction { transaction {
addLogger(Slf4jSqlDebugLogger) addLogger(Slf4jSqlDebugLogger)
val ids = categoryIds.flatten().distinct() 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 -> categoryIds.map { categoryIds ->
categories.filter { it.id in categoryIds }.toNodeList() categories.filter { it.id in categoryIds }.toNodeList()
} }
@@ -70,7 +71,8 @@ class CategoriesForMangaDataLoader : KotlinDataLoader<Int, CategoryNodeList> {
val itemsByRef = val itemsByRef =
CategoryMangaTable CategoryMangaTable
.innerJoin(CategoryTable) .innerJoin(CategoryTable)
.select { CategoryMangaTable.manga inList ids } .selectAll()
.where { CategoryMangaTable.manga inList ids }
.map { Pair(it[CategoryMangaTable.manga].value, CategoryType(it)) } .map { Pair(it[CategoryMangaTable.manga].value, CategoryType(it)) }
.groupBy { it.first } .groupBy { it.first }
.mapValues { it.value.map { pair -> pair.second } } .mapValues { it.value.map { pair -> pair.second } }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,6 @@ import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.batchInsert import org.jetbrains.exposed.sql.batchInsert
import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.deleteWhere
import org.jetbrains.exposed.sql.insertAndGetId import org.jetbrains.exposed.sql.insertAndGetId
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update
@@ -67,14 +66,15 @@ class CategoryMutation {
transaction { transaction {
val meta = val meta =
CategoryMetaTable CategoryMetaTable
.select { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) } .selectAll()
.where { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) }
.firstOrNull() .firstOrNull()
CategoryMetaTable.deleteWhere { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) } CategoryMetaTable.deleteWhere { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) }
val category = val category =
transaction { transaction {
CategoryType(CategoryTable.select { CategoryTable.id eq categoryId }.first()) CategoryType(CategoryTable.selectAll().where { CategoryTable.id eq categoryId }.first())
} }
if (meta != null) { if (meta != null) {
@@ -160,7 +160,7 @@ class CategoryMutation {
val category = val category =
transaction { transaction {
CategoryType(CategoryTable.select { CategoryTable.id eq id }.first()) CategoryType(CategoryTable.selectAll().where { CategoryTable.id eq id }.first())
} }
UpdateCategoryPayload( UpdateCategoryPayload(
@@ -177,7 +177,7 @@ class CategoryMutation {
val categories = val categories =
transaction { transaction {
CategoryTable.select { CategoryTable.id inList ids }.map { CategoryType(it) } CategoryTable.selectAll().where { CategoryTable.id inList ids }.map { CategoryType(it) }
} }
UpdateCategoriesPayload( UpdateCategoriesPayload(
@@ -207,7 +207,8 @@ class CategoryMutation {
transaction { transaction {
val currentOrder = val currentOrder =
CategoryTable CategoryTable
.select { CategoryTable.id eq categoryId } .selectAll()
.where { CategoryTable.id eq categoryId }
.first()[CategoryTable.order] .first()[CategoryTable.order]
if (currentOrder != position) { if (currentOrder != position) {
@@ -258,7 +259,7 @@ class CategoryMutation {
asDataFetcherResult { asDataFetcherResult {
val (clientMutationId, name, order, default, includeInUpdate, includeInDownload) = input val (clientMutationId, name, order, default, includeInUpdate, includeInDownload) = input
transaction { transaction {
require(CategoryTable.select { CategoryTable.name eq input.name }.isEmpty()) { require(CategoryTable.selectAll().where { CategoryTable.name eq input.name }.isEmpty()) {
"'name' must be unique" "'name' must be unique"
} }
} }
@@ -296,7 +297,7 @@ class CategoryMutation {
Category.normalizeCategories() Category.normalizeCategories()
CategoryType(CategoryTable.select { CategoryTable.id eq id }.first()) CategoryType(CategoryTable.selectAll().where { CategoryTable.id eq id }.first())
} }
CreateCategoryPayload(clientMutationId, category) CreateCategoryPayload(clientMutationId, category)
@@ -328,14 +329,16 @@ class CategoryMutation {
transaction { transaction {
val category = val category =
CategoryTable CategoryTable
.select { CategoryTable.id eq categoryId } .selectAll()
.where { CategoryTable.id eq categoryId }
.firstOrNull() .firstOrNull()
val mangas = val mangas =
transaction { transaction {
MangaTable MangaTable
.innerJoin(CategoryMangaTable) .innerJoin(CategoryMangaTable)
.select { CategoryMangaTable.category eq categoryId } .selectAll()
.where { CategoryMangaTable.category eq categoryId }
.map { MangaType(it) } .map { MangaType(it) }
} }
@@ -401,7 +404,8 @@ class CategoryMutation {
patch.addToCategories.forEach { categoryId -> patch.addToCategories.forEach { categoryId ->
val existingMapping = val existingMapping =
CategoryMangaTable CategoryMangaTable
.select { .selectAll()
.where {
(CategoryMangaTable.manga eq mangaId) and (CategoryMangaTable.category eq categoryId) (CategoryMangaTable.manga eq mangaId) and (CategoryMangaTable.category eq categoryId)
}.isNotEmpty() }.isNotEmpty()
@@ -428,7 +432,7 @@ class CategoryMutation {
val manga = val manga =
transaction { transaction {
MangaType(MangaTable.select { MangaTable.id eq id }.first()) MangaType(MangaTable.selectAll().where { MangaTable.id eq id }.first())
} }
UpdateMangaCategoriesPayload( UpdateMangaCategoriesPayload(
@@ -445,7 +449,7 @@ class CategoryMutation {
val mangas = val mangas =
transaction { transaction {
MangaTable.select { MangaTable.id inList ids }.map { MangaType(it) } MangaTable.selectAll().where { MangaTable.id inList ids }.map { MangaType(it) }
} }
UpdateMangasCategoriesPayload( UpdateMangasCategoriesPayload(

View File

@@ -5,7 +5,7 @@ import org.jetbrains.exposed.dao.id.EntityID
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.deleteWhere 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.statements.BatchUpdateStatement
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.asDataFetcherResult import suwayomi.tachidesk.graphql.asDataFetcherResult
@@ -65,8 +65,8 @@ class ChapterMutation {
val chapterIdToPageCount = val chapterIdToPageCount =
if (patch.lastPageRead != null) { if (patch.lastPageRead != null) {
ChapterTable ChapterTable
.slice(ChapterTable.id, ChapterTable.pageCount) .select(ChapterTable.id, ChapterTable.pageCount)
.select { ChapterTable.id inList ids } .where { ChapterTable.id inList ids }
.groupBy { it[ChapterTable.id].value } .groupBy { it[ChapterTable.id].value }
.mapValues { it.value.firstOrNull()?.let { it[ChapterTable.pageCount] } } .mapValues { it.value.firstOrNull()?.let { it[ChapterTable.pageCount] } }
} else { } else {
@@ -103,7 +103,7 @@ class ChapterMutation {
val chapter = val chapter =
transaction { transaction {
ChapterType(ChapterTable.select { ChapterTable.id eq id }.first()) ChapterType(ChapterTable.selectAll().where { ChapterTable.id eq id }.first())
} }
UpdateChapterPayload( UpdateChapterPayload(
@@ -120,7 +120,7 @@ class ChapterMutation {
val chapters = val chapters =
transaction { transaction {
ChapterTable.select { ChapterTable.id inList ids }.map { ChapterType(it) } ChapterTable.selectAll().where { ChapterTable.id inList ids }.map { ChapterType(it) }
} }
UpdateChaptersPayload( UpdateChaptersPayload(
@@ -149,7 +149,8 @@ class ChapterMutation {
val chapters = val chapters =
transaction { transaction {
ChapterTable ChapterTable
.select { ChapterTable.manga eq mangaId } .selectAll()
.where { ChapterTable.manga eq mangaId }
.orderBy(ChapterTable.sourceOrder) .orderBy(ChapterTable.sourceOrder)
.map { ChapterType(it) } .map { ChapterType(it) }
} }
@@ -201,14 +202,15 @@ class ChapterMutation {
transaction { transaction {
val meta = val meta =
ChapterMetaTable ChapterMetaTable
.select { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) } .selectAll()
.where { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
.firstOrNull() .firstOrNull()
ChapterMetaTable.deleteWhere { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) } ChapterMetaTable.deleteWhere { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
val chapter = val chapter =
transaction { transaction {
ChapterType(ChapterTable.select { ChapterTable.id eq chapterId }.first()) ChapterType(ChapterTable.selectAll().where { ChapterTable.id eq chapterId }.first())
} }
if (meta != null) { if (meta != null) {

View File

@@ -3,7 +3,7 @@ package suwayomi.tachidesk.graphql.mutations
import graphql.execution.DataFetcherResult import graphql.execution.DataFetcherResult
import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withTimeout import kotlinx.coroutines.withTimeout
import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.asDataFetcherResult import suwayomi.tachidesk.graphql.asDataFetcherResult
import suwayomi.tachidesk.graphql.types.ChapterType import suwayomi.tachidesk.graphql.types.ChapterType
@@ -39,7 +39,8 @@ class DownloadMutation {
chapters = chapters =
transaction { transaction {
ChapterTable ChapterTable
.select { ChapterTable.id inList chapters } .selectAll()
.where { ChapterTable.id inList chapters }
.map { ChapterType(it) } .map { ChapterType(it) }
}, },
) )
@@ -66,7 +67,7 @@ class DownloadMutation {
clientMutationId = clientMutationId, clientMutationId = clientMutationId,
chapters = chapters =
transaction { transaction {
ChapterType(ChapterTable.select { ChapterTable.id eq chapter }.first()) ChapterType(ChapterTable.selectAll().where { ChapterTable.id eq chapter }.first())
}, },
) )
} }

View File

@@ -3,7 +3,7 @@ package suwayomi.tachidesk.graphql.mutations
import eu.kanade.tachiyomi.source.local.LocalSource import eu.kanade.tachiyomi.source.local.LocalSource
import graphql.execution.DataFetcherResult import graphql.execution.DataFetcherResult
import io.javalin.http.UploadedFile 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 org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.asDataFetcherResult import suwayomi.tachidesk.graphql.asDataFetcherResult
import suwayomi.tachidesk.graphql.types.ExtensionType import suwayomi.tachidesk.graphql.types.ExtensionType
@@ -49,7 +49,8 @@ class ExtensionMutation {
val extensions = val extensions =
transaction { transaction {
ExtensionTable ExtensionTable
.select { ExtensionTable.pkgName inList ids } .selectAll()
.where { ExtensionTable.pkgName inList ids }
.map { ExtensionType(it) } .map { ExtensionType(it) }
} }
@@ -82,7 +83,8 @@ class ExtensionMutation {
val extension = val extension =
transaction { transaction {
ExtensionTable ExtensionTable
.select { ExtensionTable.pkgName eq id } .selectAll()
.where { ExtensionTable.pkgName eq id }
.firstOrNull() .firstOrNull()
?.let { ExtensionType(it) } ?.let { ExtensionType(it) }
} }
@@ -105,7 +107,8 @@ class ExtensionMutation {
val extensions = val extensions =
transaction { transaction {
ExtensionTable ExtensionTable
.select { ExtensionTable.pkgName inList ids } .selectAll()
.where { ExtensionTable.pkgName inList ids }
.map { ExtensionType(it) } .map { ExtensionType(it) }
} }
@@ -136,7 +139,8 @@ class ExtensionMutation {
val extensions = val extensions =
transaction { transaction {
ExtensionTable ExtensionTable
.select { ExtensionTable.name neq LocalSource.EXTENSION_NAME } .selectAll()
.where { ExtensionTable.name neq LocalSource.EXTENSION_NAME }
.map { ExtensionType(it) } .map { ExtensionType(it) }
} }
@@ -167,7 +171,8 @@ class ExtensionMutation {
asDataFetcherResult { asDataFetcherResult {
Extension.installExternalExtension(extensionFile.content(), extensionFile.filename()) 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( InstallExternalExtensionPayload(
clientMutationId, clientMutationId,

View File

@@ -4,7 +4,7 @@ import graphql.execution.DataFetcherResult
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.deleteWhere 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.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update
import suwayomi.tachidesk.graphql.asDataFetcherResult import suwayomi.tachidesk.graphql.asDataFetcherResult
@@ -75,7 +75,8 @@ class MangaMutation {
val mangas = val mangas =
transaction { transaction {
MangaTable 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) } .map { MangaTable.toDataClass(it) }
} }
@@ -98,7 +99,7 @@ class MangaMutation {
val manga = val manga =
transaction { transaction {
MangaType(MangaTable.select { MangaTable.id eq id }.first()) MangaType(MangaTable.selectAll().where { MangaTable.id eq id }.first())
} }
UpdateMangaPayload( UpdateMangaPayload(
@@ -118,7 +119,7 @@ class MangaMutation {
val mangas = val mangas =
transaction { transaction {
MangaTable.select { MangaTable.id inList ids }.map { MangaType(it) } MangaTable.selectAll().where { MangaTable.id inList ids }.map { MangaType(it) }
} }
UpdateMangasPayload( UpdateMangasPayload(
@@ -148,7 +149,7 @@ class MangaMutation {
val manga = val manga =
transaction { transaction {
MangaTable.select { MangaTable.id eq id }.first() MangaTable.selectAll().where { MangaTable.id eq id }.first()
} }
FetchMangaPayload( FetchMangaPayload(
clientMutationId = clientMutationId, clientMutationId = clientMutationId,
@@ -198,14 +199,15 @@ class MangaMutation {
transaction { transaction {
val meta = val meta =
MangaMetaTable MangaMetaTable
.select { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) } .selectAll()
.where { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) }
.firstOrNull() .firstOrNull()
MangaMetaTable.deleteWhere { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) } MangaMetaTable.deleteWhere { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) }
val manga = val manga =
transaction { transaction {
MangaType(MangaTable.select { MangaTable.id eq mangaId }.first()) MangaType(MangaTable.selectAll().where { MangaTable.id eq mangaId }.first())
} }
if (meta != null) { if (meta != null) {

View File

@@ -3,7 +3,7 @@ package suwayomi.tachidesk.graphql.mutations
import graphql.execution.DataFetcherResult import graphql.execution.DataFetcherResult
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.deleteWhere 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.transactions.transaction
import suwayomi.tachidesk.global.impl.GlobalMeta import suwayomi.tachidesk.global.impl.GlobalMeta
import suwayomi.tachidesk.global.model.table.GlobalMetaTable import suwayomi.tachidesk.global.model.table.GlobalMetaTable
@@ -49,7 +49,8 @@ class MetaMutation {
transaction { transaction {
val meta = val meta =
GlobalMetaTable GlobalMetaTable
.select { GlobalMetaTable.key eq key } .selectAll()
.where { GlobalMetaTable.key eq key }
.firstOrNull() .firstOrNull()
GlobalMetaTable.deleteWhere { GlobalMetaTable.key eq key } GlobalMetaTable.deleteWhere { GlobalMetaTable.key eq key }

View File

@@ -9,7 +9,7 @@ import graphql.execution.DataFetcherResult
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.deleteWhere 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.transactions.transaction
import suwayomi.tachidesk.graphql.asDataFetcherResult import suwayomi.tachidesk.graphql.asDataFetcherResult
import suwayomi.tachidesk.graphql.types.FilterChange import suwayomi.tachidesk.graphql.types.FilterChange
@@ -69,7 +69,8 @@ class SourceMutation {
transaction { transaction {
val meta = val meta =
SourceMetaTable SourceMetaTable
.select { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) } .selectAll()
.where { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) }
.firstOrNull() .firstOrNull()
SourceMetaTable.deleteWhere { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) } SourceMetaTable.deleteWhere { (SourceMetaTable.ref eq sourceId) and (SourceMetaTable.key eq key) }
@@ -77,7 +78,8 @@ class SourceMutation {
val source = val source =
transaction { transaction {
SourceTable SourceTable
.select { SourceTable.id eq sourceId } .selectAll()
.where { SourceTable.id eq sourceId }
.firstOrNull() .firstOrNull()
?.let { SourceType(it) } ?.let { SourceType(it) }
} }
@@ -143,7 +145,8 @@ class SourceMutation {
val mangas = val mangas =
transaction { transaction {
MangaTable MangaTable
.select { MangaTable.id inList mangaIds } .selectAll()
.where { MangaTable.id inList mangaIds }
.map { MangaType(it) } .map { MangaType(it) }
}.sortedBy { }.sortedBy {
mangaIds.indexOf(it.id) mangaIds.indexOf(it.id)
@@ -199,7 +202,7 @@ class SourceMutation {
preferences = Source.getSourcePreferencesRaw(sourceId).map { preferenceOf(it) }, preferences = Source.getSourcePreferencesRaw(sourceId).map { preferenceOf(it) },
source = source =
transaction { transaction {
SourceType(SourceTable.select { SourceTable.id eq sourceId }.first())!! SourceType(SourceTable.selectAll().where { SourceTable.id eq sourceId }.first())!!
}, },
) )
} }

View File

@@ -4,7 +4,7 @@ import com.expediagroup.graphql.generator.annotations.GraphQLDeprecated
import com.expediagroup.graphql.generator.annotations.GraphQLDescription import com.expediagroup.graphql.generator.annotations.GraphQLDescription
import graphql.execution.DataFetcherResult import graphql.execution.DataFetcherResult
import org.jetbrains.exposed.sql.and 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.transactions.transaction
import suwayomi.tachidesk.graphql.asDataFetcherResult import suwayomi.tachidesk.graphql.asDataFetcherResult
import suwayomi.tachidesk.graphql.types.TrackRecordType import suwayomi.tachidesk.graphql.types.TrackRecordType
@@ -127,7 +127,8 @@ class TrackMutation {
val trackRecord = val trackRecord =
transaction { transaction {
TrackRecordTable TrackRecordTable
.select { .selectAll()
.where {
TrackRecordTable.mangaId eq mangaId and (TrackRecordTable.trackerId eq trackerId) TrackRecordTable.mangaId eq mangaId and (TrackRecordTable.trackerId eq trackerId)
}.first() }.first()
} }
@@ -156,7 +157,8 @@ class TrackMutation {
val trackRecord = val trackRecord =
transaction { transaction {
TrackRecordTable TrackRecordTable
.select { .selectAll()
.where {
TrackRecordTable.id eq recordId TrackRecordTable.id eq recordId
}.first() }.first()
} }
@@ -187,7 +189,8 @@ class TrackMutation {
val trackRecord = val trackRecord =
transaction { transaction {
TrackRecordTable TrackRecordTable
.select { .selectAll()
.where {
TrackRecordTable.id eq recordId TrackRecordTable.id eq recordId
}.firstOrNull() }.firstOrNull()
} }
@@ -217,7 +220,8 @@ class TrackMutation {
val trackRecords = val trackRecords =
transaction { transaction {
TrackRecordTable TrackRecordTable
.select { TrackRecordTable.mangaId eq mangaId } .selectAll()
.where { TrackRecordTable.mangaId eq mangaId }
.toList() .toList()
} }
TrackProgressPayload( TrackProgressPayload(
@@ -262,7 +266,8 @@ class TrackMutation {
val trackRecord = val trackRecord =
transaction { transaction {
TrackRecordTable TrackRecordTable
.select { .selectAll()
.where {
TrackRecordTable.id eq input.recordId TrackRecordTable.id eq input.recordId
}.firstOrNull() }.firstOrNull()
} }

View File

@@ -3,7 +3,7 @@ package suwayomi.tachidesk.graphql.mutations
import graphql.execution.DataFetcherResult import graphql.execution.DataFetcherResult
import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.first
import kotlinx.coroutines.withTimeout import kotlinx.coroutines.withTimeout
import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.asDataFetcherResult import suwayomi.tachidesk.graphql.asDataFetcherResult
import suwayomi.tachidesk.graphql.types.UpdateStatus import suwayomi.tachidesk.graphql.types.UpdateStatus
@@ -61,7 +61,7 @@ class UpdateMutation {
fun updateCategoryManga(input: UpdateCategoryMangaInput): CompletableFuture<DataFetcherResult<UpdateCategoryMangaPayload?>> { fun updateCategoryManga(input: UpdateCategoryMangaInput): CompletableFuture<DataFetcherResult<UpdateCategoryMangaPayload?>> {
val categories = val categories =
transaction { transaction {
CategoryTable.select { CategoryTable.id inList input.categories }.map { CategoryTable.selectAll().where { CategoryTable.id inList input.categories }.map {
CategoryTable.toDataClass(it) CategoryTable.toDataClass(it)
} }
} }

View File

@@ -48,7 +48,7 @@ class CategoryQuery {
): CompletableFuture<CategoryType> = dataFetchingEnvironment.getValueFromDataLoader("CategoryDataLoader", id) ): CompletableFuture<CategoryType> = dataFetchingEnvironment.getValueFromDataLoader("CategoryDataLoader", id)
enum class CategoryOrderBy( enum class CategoryOrderBy(
override val column: Column<out Comparable<*>>, override val column: Column<*>,
) : OrderBy<CategoryType> { ) : OrderBy<CategoryType> {
ID(CategoryTable.id), ID(CategoryTable.id),
NAME(CategoryTable.name), NAME(CategoryTable.name),
@@ -170,7 +170,7 @@ class CategoryQuery {
) )
if (first != null) { if (first != null) {
res.limit(first, offset?.toLong() ?: 0) res.limit(first).offset(offset?.toLong() ?: 0)
} else if (last != null) { } else if (last != null) {
res.limit(last) res.limit(last)
} }

View File

@@ -57,7 +57,7 @@ class ChapterQuery {
): CompletableFuture<ChapterType> = dataFetchingEnvironment.getValueFromDataLoader("ChapterDataLoader", id) ): CompletableFuture<ChapterType> = dataFetchingEnvironment.getValueFromDataLoader("ChapterDataLoader", id)
enum class ChapterOrderBy( enum class ChapterOrderBy(
override val column: Column<out Comparable<*>>, override val column: Column<*>,
) : OrderBy<ChapterType> { ) : OrderBy<ChapterType> {
ID(ChapterTable.id), ID(ChapterTable.id),
SOURCE_ORDER(ChapterTable.sourceOrder), SOURCE_ORDER(ChapterTable.sourceOrder),
@@ -254,7 +254,7 @@ class ChapterQuery {
) )
if (first != null) { if (first != null) {
res.limit(first, offset?.toLong() ?: 0) res.limit(first).offset(offset?.toLong() ?: 0)
} else if (last != null) { } else if (last != null) {
res.limit(last) res.limit(last)
} }

View File

@@ -49,7 +49,7 @@ class ExtensionQuery {
): CompletableFuture<ExtensionType> = dataFetchingEnvironment.getValueFromDataLoader("ExtensionDataLoader", pkgName) ): CompletableFuture<ExtensionType> = dataFetchingEnvironment.getValueFromDataLoader("ExtensionDataLoader", pkgName)
enum class ExtensionOrderBy( enum class ExtensionOrderBy(
override val column: Column<out Comparable<*>>, override val column: Column<*>,
) : OrderBy<ExtensionType> { ) : OrderBy<ExtensionType> {
PKG_NAME(ExtensionTable.pkgName), PKG_NAME(ExtensionTable.pkgName),
NAME(ExtensionTable.name), NAME(ExtensionTable.name),
@@ -204,7 +204,7 @@ class ExtensionQuery {
) )
if (first != null) { if (first != null) {
res.limit(first, offset?.toLong() ?: 0) res.limit(first).offset(offset?.toLong() ?: 0)
} else if (last != null) { } else if (last != null) {
res.limit(last) res.limit(last)
} }

View File

@@ -15,7 +15,6 @@ import org.jetbrains.exposed.sql.Op
import org.jetbrains.exposed.sql.SortOrder import org.jetbrains.exposed.sql.SortOrder
import org.jetbrains.exposed.sql.SqlExpressionBuilder.greater import org.jetbrains.exposed.sql.SqlExpressionBuilder.greater
import org.jetbrains.exposed.sql.SqlExpressionBuilder.less import org.jetbrains.exposed.sql.SqlExpressionBuilder.less
import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.graphql.queries.filter.BooleanFilter import suwayomi.tachidesk.graphql.queries.filter.BooleanFilter
import suwayomi.tachidesk.graphql.queries.filter.ComparableScalarFilter 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.andFilterWithCompareEntity
import suwayomi.tachidesk.graphql.queries.filter.andFilterWithCompareString import suwayomi.tachidesk.graphql.queries.filter.andFilterWithCompareString
import suwayomi.tachidesk.graphql.queries.filter.applyOps 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.Cursor
import suwayomi.tachidesk.graphql.server.primitives.Order import suwayomi.tachidesk.graphql.server.primitives.Order
import suwayomi.tachidesk.graphql.server.primitives.OrderBy import suwayomi.tachidesk.graphql.server.primitives.OrderBy
@@ -53,7 +51,7 @@ class MangaQuery {
): CompletableFuture<MangaType> = dataFetchingEnvironment.getValueFromDataLoader("MangaDataLoader", id) ): CompletableFuture<MangaType> = dataFetchingEnvironment.getValueFromDataLoader("MangaDataLoader", id)
enum class MangaOrderBy( enum class MangaOrderBy(
override val column: Column<out Comparable<*>>, override val column: Column<*>,
) : OrderBy<MangaType> { ) : OrderBy<MangaType> {
ID(MangaTable.id), ID(MangaTable.id),
TITLE(MangaTable.title), TITLE(MangaTable.title),
@@ -242,11 +240,8 @@ class MangaQuery {
val res = val res =
MangaTable MangaTable
.leftJoin(CategoryMangaTable) .leftJoin(CategoryMangaTable)
.slice( .select(MangaTable.columns)
distinctOn(MangaTable.id), .withDistinctOn(MangaTable.id)
*(MangaTable.columns).toTypedArray(),
*(CategoryMangaTable.columns).toTypedArray(),
).selectAll()
res.applyOps(condition, filter) res.applyOps(condition, filter)
@@ -274,7 +269,7 @@ class MangaQuery {
) )
if (first != null) { if (first != null) {
res.limit(first, offset?.toLong() ?: 0) res.limit(first).offset(offset?.toLong() ?: 0)
} else if (last != null) { } else if (last != null) {
res.limit(last) res.limit(last)
} }

View File

@@ -44,7 +44,7 @@ class MetaQuery {
): CompletableFuture<GlobalMetaType> = dataFetchingEnvironment.getValueFromDataLoader("GlobalMetaDataLoader", key) ): CompletableFuture<GlobalMetaType> = dataFetchingEnvironment.getValueFromDataLoader("GlobalMetaDataLoader", key)
enum class MetaOrderBy( enum class MetaOrderBy(
override val column: Column<out Comparable<*>>, override val column: Column<*>,
) : OrderBy<GlobalMetaType> { ) : OrderBy<GlobalMetaType> {
KEY(GlobalMetaTable.key), KEY(GlobalMetaTable.key),
VALUE(GlobalMetaTable.value), VALUE(GlobalMetaTable.value),
@@ -154,7 +154,7 @@ class MetaQuery {
) )
if (first != null) { if (first != null) {
res.limit(first, offset?.toLong() ?: 0) res.limit(first).offset(offset?.toLong() ?: 0)
} else if (last != null) { } else if (last != null) {
res.limit(last) res.limit(last)
} }

View File

@@ -48,7 +48,7 @@ class SourceQuery {
): CompletableFuture<SourceType> = dataFetchingEnvironment.getValueFromDataLoader("SourceDataLoader", id) ): CompletableFuture<SourceType> = dataFetchingEnvironment.getValueFromDataLoader("SourceDataLoader", id)
enum class SourceOrderBy( enum class SourceOrderBy(
override val column: Column<out Comparable<*>>, override val column: Column<*>,
) : OrderBy<SourceType> { ) : OrderBy<SourceType> {
ID(SourceTable.id), ID(SourceTable.id),
NAME(SourceTable.name), NAME(SourceTable.name),
@@ -170,7 +170,7 @@ class SourceQuery {
) )
if (first != null) { if (first != null) {
res.limit(first, offset?.toLong() ?: 0) res.limit(first).offset(offset?.toLong() ?: 0)
} else if (last != null) { } else if (last != null) {
res.limit(last) res.limit(last)
} }

View File

@@ -244,7 +244,7 @@ class TrackQuery {
dataFetchingEnvironment.getValueFromDataLoader<Int, TrackRecordType>("TrackRecordDataLoader", id) dataFetchingEnvironment.getValueFromDataLoader<Int, TrackRecordType>("TrackRecordDataLoader", id)
enum class TrackRecordOrderBy( enum class TrackRecordOrderBy(
override val column: Column<out Comparable<*>>, override val column: Column<*>,
) : OrderBy<TrackRecordType> { ) : OrderBy<TrackRecordType> {
ID(TrackRecordTable.id), ID(TrackRecordTable.id),
MANGA_ID(TrackRecordTable.mangaId), MANGA_ID(TrackRecordTable.mangaId),
@@ -430,7 +430,7 @@ class TrackQuery {
) )
if (first != null) { if (first != null) {
res.limit(first, offset?.toLong() ?: 0) res.limit(first).offset(offset?.toLong() ?: 0)
} else if (last != null) { } else if (last != null) {
res.limit(last) res.limit(last)
} }

View File

@@ -466,12 +466,12 @@ fun <T : String, S : T?> andFilterWithCompareString(
} }
opAnd.andWhere(filter.distinctFromInsensitive, filter.distinctFromInsensitiveAll, filter.distinctFromInsensitiveAny) { 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<S>) } opAnd.andWhere(filter.inInsensitive) { column.upperCase() inList (it.map { it.uppercase() }) }
opAnd.andWhere(filter.notInInsensitive) { column.upperCase() notInList (it.map { it.uppercase() } as List<S>) } opAnd.andWhere(filter.notInInsensitive) { column.upperCase() notInList (it.map { it.uppercase() }) }
opAnd.andWhere(filter.lessThanInsensitive) { column.upperCase() less it.uppercase() } opAnd.andWhere(filter.lessThanInsensitive) { column.upperCase() less it.uppercase() }
opAnd.andWhere(filter.lessThanOrEqualToInsensitive) { column.upperCase() lessEq it.uppercase() } opAnd.andWhere(filter.lessThanOrEqualToInsensitive) { column.upperCase() lessEq it.uppercase() }
@@ -539,38 +539,21 @@ class OpAnd(
) = andWhere(value) { column eq it } ) = andWhere(value) { column eq it }
} }
@Suppress("UNCHECKED_CAST")
fun <T : Comparable<T>, S : T?> andFilterWithCompare( fun <T : Comparable<T>, S : T?> andFilterWithCompare(
column: Column<S>, column: Column<S>,
filter: ComparableScalarFilter<T>?, filter: ComparableScalarFilter<T>?,
): Op<Boolean>? { ): Op<Boolean>? {
filter ?: return null filter ?: return null
val opAnd = OpAnd(andFilter(column, filter)) val opAnd = OpAnd()
opAnd.andWhere(filter.lessThan) { column less it } opAnd.andWhere(filter.lessThan) { column less it }
opAnd.andWhere(filter.lessThanOrEqualTo) { column lessEq it } opAnd.andWhere(filter.lessThanOrEqualTo) { column lessEq it }
opAnd.andWhere(filter.greaterThan) { column greater it } opAnd.andWhere(filter.greaterThan) { column greater it }
opAnd.andWhere(filter.greaterThanOrEqualTo) { column greaterEq it } opAnd.andWhere(filter.greaterThanOrEqualTo) { column greaterEq it }
return opAnd.op
}
fun <T : Comparable<T>> andFilterWithCompareEntity(
column: Column<EntityID<T>>,
filter: ComparableScalarFilter<T>?,
): Op<Boolean>? {
@Suppress("UNCHECKED_CAST")
return andFilterWithCompare(column as Column<T>, filter)
}
@Suppress("UNCHECKED_CAST")
fun <T : Comparable<T>, S : T?> andFilter(
column: Column<S>,
filter: ScalarFilter<T>?,
): Op<Boolean>? {
filter ?: return null
val opAnd = OpAnd()
opAnd.andWhere(filter.isNull) { if (it) column.isNull() else column.isNotNull() } opAnd.andWhere(filter.isNull) { if (it) column.isNull() else column.isNotNull() }
opAnd.andWhere(filter.equalTo) { column eq it as S } 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.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.distinctFrom, filter.distinctFromAll, filter.distinctFromAny) { DistinctFromOp.distinctFrom(column, it as S) }
@@ -581,5 +564,34 @@ fun <T : Comparable<T>, S : T?> andFilter(
if (!filter.notIn.isNullOrEmpty()) { if (!filter.notIn.isNullOrEmpty()) {
opAnd.andWhere(filter.notIn) { column notInList it as List<S> } opAnd.andWhere(filter.notIn) { column notInList it as List<S> }
} }
return opAnd.op
}
fun <T : Comparable<T>> andFilterWithCompareEntity(
column: Column<EntityID<T>>,
filter: ComparableScalarFilter<T>?,
): Op<Boolean>? {
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 }
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 }
}
if (!filter.notIn.isNullOrEmpty()) {
opAnd.andWhere(filter.notIn) { column notInList it }
}
return opAnd.op return opAnd.op
} }

View File

@@ -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<Boolean?> =
customBooleanFunction(
functionName = "DISTINCT ON",
postfix = " TRUE",
params = expressions,
)
fun customBooleanFunction(
functionName: String,
postfix: String = "",
vararg params: Expression<*>,
): CustomFunction<Boolean?> =
object : CustomFunction<Boolean?>(functionName, BooleanColumnType(), *params) {
override fun toQueryBuilder(queryBuilder: QueryBuilder) {
super.toQueryBuilder(queryBuilder)
if (postfix.isNotEmpty()) {
queryBuilder.append(postfix)
}
}
}

View File

@@ -13,7 +13,7 @@ import org.jetbrains.exposed.sql.andWhere
import org.jetbrains.exposed.sql.or import org.jetbrains.exposed.sql.or
interface OrderBy<T> { interface OrderBy<T> {
val column: Column<out Comparable<*>> val column: Column<*>
fun asCursor(type: T): Cursor fun asCursor(type: T): Cursor

View File

@@ -12,6 +12,7 @@ import com.expediagroup.graphql.server.types.GraphQLRequest
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.convertValue import com.fasterxml.jackson.module.kotlin.convertValue
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import io.github.oshai.kotlinlogging.KotlinLogging
import io.javalin.websocket.WsContext import io.javalin.websocket.WsContext
import io.javalin.websocket.WsMessageContext import io.javalin.websocket.WsMessageContext
import kotlinx.coroutines.currentCoroutineContext import kotlinx.coroutines.currentCoroutineContext
@@ -24,7 +25,6 @@ import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.job import kotlinx.coroutines.job
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import mu.KotlinLogging
import org.eclipse.jetty.websocket.api.CloseStatus import org.eclipse.jetty.websocket.api.CloseStatus
import suwayomi.tachidesk.graphql.server.TachideskGraphQLContextFactory import suwayomi.tachidesk.graphql.server.TachideskGraphQLContextFactory
import suwayomi.tachidesk.graphql.server.subscriptions.SubscriptionOperationMessage.ClientMessages.GQL_CONNECTION_INIT import suwayomi.tachidesk.graphql.server.subscriptions.SubscriptionOperationMessage.ClientMessages.GQL_CONNECTION_INIT

View File

@@ -68,7 +68,7 @@ class ChapterType(
row[ChapterTable.fetchedAt], row[ChapterTable.fetchedAt],
row[ChapterTable.isDownloaded], row[ChapterTable.isDownloaded],
row[ChapterTable.pageCount], 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( constructor(dataClass: ChapterDataClass) : this(

View File

@@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.source.ConfigurableSource
import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.FilterList
import graphql.schema.DataFetchingEnvironment import graphql.schema.DataFetchingEnvironment
import org.jetbrains.exposed.sql.ResultRow 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.Cursor
import suwayomi.tachidesk.graphql.server.primitives.Edge import suwayomi.tachidesk.graphql.server.primitives.Edge
import suwayomi.tachidesk.graphql.server.primitives.Node import suwayomi.tachidesk.graphql.server.primitives.Node
@@ -92,7 +92,8 @@ fun SourceType(row: ResultRow): SourceType? {
row row
} else { } else {
ExtensionTable ExtensionTable
.select { ExtensionTable.id eq row[SourceTable.extension] } .selectAll()
.where { ExtensionTable.id eq row[SourceTable.extension] }
.first() .first()
} }

View File

@@ -7,8 +7,8 @@ package suwayomi.tachidesk.manga.controller
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import io.github.oshai.kotlinlogging.KotlinLogging
import io.javalin.http.HttpStatus import io.javalin.http.HttpStatus
import mu.KotlinLogging
import suwayomi.tachidesk.manga.impl.extension.Extension import suwayomi.tachidesk.manga.impl.extension.Extension
import suwayomi.tachidesk.manga.impl.extension.ExtensionsList import suwayomi.tachidesk.manga.impl.extension.ExtensionsList
import suwayomi.tachidesk.manga.model.dataclass.ExtensionDataClass import suwayomi.tachidesk.manga.model.dataclass.ExtensionDataClass

View File

@@ -7,9 +7,9 @@ package suwayomi.tachidesk.manga.controller
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import io.github.oshai.kotlinlogging.KotlinLogging
import io.javalin.http.HttpStatus import io.javalin.http.HttpStatus
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import mu.KotlinLogging
import suwayomi.tachidesk.manga.impl.track.Track import suwayomi.tachidesk.manga.impl.track.Track
import suwayomi.tachidesk.manga.model.dataclass.TrackerDataClass import suwayomi.tachidesk.manga.model.dataclass.TrackerDataClass
import suwayomi.tachidesk.server.JavalinSetup.future import suwayomi.tachidesk.server.JavalinSetup.future

View File

@@ -1,8 +1,8 @@
package suwayomi.tachidesk.manga.controller package suwayomi.tachidesk.manga.controller
import io.github.oshai.kotlinlogging.KotlinLogging
import io.javalin.http.HttpStatus import io.javalin.http.HttpStatus
import io.javalin.websocket.WsConfig import io.javalin.websocket.WsConfig
import mu.KotlinLogging
import suwayomi.tachidesk.manga.impl.Category import suwayomi.tachidesk.manga.impl.Category
import suwayomi.tachidesk.manga.impl.Chapter import suwayomi.tachidesk.manga.impl.Chapter
import suwayomi.tachidesk.manga.impl.update.IUpdater import suwayomi.tachidesk.manga.impl.update.IUpdater

View File

@@ -14,7 +14,6 @@ import org.jetbrains.exposed.sql.andWhere
import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.deleteWhere
import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.insertAndGetId import org.jetbrains.exposed.sql.insertAndGetId
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update
@@ -34,7 +33,7 @@ object Category {
if (name.equals(DEFAULT_CATEGORY_NAME, ignoreCase = true)) return -1 if (name.equals(DEFAULT_CATEGORY_NAME, ignoreCase = true)) return -1
return transaction { return transaction {
if (CategoryTable.select { CategoryTable.name eq name }.firstOrNull() == null) { if (CategoryTable.selectAll().where { CategoryTable.name eq name }.firstOrNull() == null) {
val newCategoryId = val newCategoryId =
CategoryTable CategoryTable
.insertAndGetId { .insertAndGetId {
@@ -85,7 +84,8 @@ object Category {
transaction { transaction {
val categories = val categories =
CategoryTable CategoryTable
.select { .selectAll()
.where {
CategoryTable.id neq DEFAULT_CATEGORY_ID CategoryTable.id neq DEFAULT_CATEGORY_ID
}.orderBy(CategoryTable.order to SortOrder.ASC) }.orderBy(CategoryTable.order to SortOrder.ASC)
.toMutableList() .toMutableList()
@@ -126,7 +126,8 @@ object Category {
transaction { transaction {
MangaTable MangaTable
.leftJoin(CategoryMangaTable) .leftJoin(CategoryMangaTable)
.select { MangaTable.inLibrary eq true } .selectAll()
.where { MangaTable.inLibrary eq true }
.andWhere { CategoryMangaTable.manga.isNull() } .andWhere { CategoryMangaTable.manga.isNull() }
.empty() .empty()
.not() .not()
@@ -153,7 +154,7 @@ object Category {
fun getCategoryById(categoryId: Int): CategoryDataClass? = fun getCategoryById(categoryId: Int): CategoryDataClass? =
transaction { transaction {
CategoryTable.select { CategoryTable.id eq categoryId }.firstOrNull()?.let { CategoryTable.selectAll().where { CategoryTable.id eq categoryId }.firstOrNull()?.let {
CategoryTable.toDataClass(it) CategoryTable.toDataClass(it)
} }
} }
@@ -163,12 +164,14 @@ object Category {
if (categoryId == DEFAULT_CATEGORY_ID) { if (categoryId == DEFAULT_CATEGORY_ID) {
MangaTable MangaTable
.leftJoin(CategoryMangaTable) .leftJoin(CategoryMangaTable)
.select { MangaTable.inLibrary eq true } .selectAll()
.where { MangaTable.inLibrary eq true }
.andWhere { CategoryMangaTable.manga.isNull() } .andWhere { CategoryMangaTable.manga.isNull() }
} else { } else {
CategoryMangaTable CategoryMangaTable
.leftJoin(MangaTable) .leftJoin(MangaTable)
.select { CategoryMangaTable.category eq categoryId } .selectAll()
.where { CategoryMangaTable.category eq categoryId }
.andWhere { MangaTable.inLibrary eq true } .andWhere { MangaTable.inLibrary eq true }
}.count().toInt() }.count().toInt()
} }
@@ -176,7 +179,8 @@ object Category {
fun getCategoryMetaMap(categoryId: Int): Map<String, String> = fun getCategoryMetaMap(categoryId: Int): Map<String, String> =
transaction { transaction {
CategoryMetaTable CategoryMetaTable
.select { CategoryMetaTable.ref eq categoryId } .selectAll()
.where { CategoryMetaTable.ref eq categoryId }
.associate { it[CategoryMetaTable.key] to it[CategoryMetaTable.value] } .associate { it[CategoryMetaTable.key] to it[CategoryMetaTable.value] }
} }
@@ -188,7 +192,7 @@ object Category {
transaction { transaction {
val meta = val meta =
transaction { 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() }.firstOrNull()
if (meta == null) { if (meta == null) {

View File

@@ -17,7 +17,7 @@ import org.jetbrains.exposed.sql.deleteWhere
import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.leftJoin import org.jetbrains.exposed.sql.leftJoin
import org.jetbrains.exposed.sql.max 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.transactions.transaction
import org.jetbrains.exposed.sql.wrapAsExpression import org.jetbrains.exposed.sql.wrapAsExpression
import suwayomi.tachidesk.manga.impl.Category.DEFAULT_CATEGORY_ID import suwayomi.tachidesk.manga.impl.Category.DEFAULT_CATEGORY_ID
@@ -39,7 +39,8 @@ object CategoryManga {
fun notAlreadyInCategory() = fun notAlreadyInCategory() =
CategoryMangaTable CategoryMangaTable
.select { .selectAll()
.where {
(CategoryMangaTable.category eq categoryId) and (CategoryMangaTable.manga eq mangaId) (CategoryMangaTable.category eq categoryId) and (CategoryMangaTable.manga eq mangaId)
}.isEmpty() }.isEmpty()
@@ -71,16 +72,16 @@ object CategoryManga {
val unreadCount = val unreadCount =
wrapAsExpression<Long>( wrapAsExpression<Long>(
ChapterTable ChapterTable
.slice( .select(
ChapterTable.id.count(), 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 = val downloadedCount =
wrapAsExpression<Long>( wrapAsExpression<Long>(
ChapterTable ChapterTable
.slice( .select(
ChapterTable.id.count(), 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") val chapterCount = ChapterTable.id.count().alias("chapter_count")
@@ -104,14 +105,14 @@ object CategoryManga {
MangaTable MangaTable
.leftJoin(ChapterTable, { MangaTable.id }, { ChapterTable.manga }) .leftJoin(ChapterTable, { MangaTable.id }, { ChapterTable.manga })
.leftJoin(CategoryMangaTable) .leftJoin(CategoryMangaTable)
.slice(columns = selectedColumns) .select(columns = selectedColumns)
.select { (MangaTable.inLibrary eq true) and CategoryMangaTable.category.isNull() } .where { (MangaTable.inLibrary eq true) and CategoryMangaTable.category.isNull() }
} else { } else {
MangaTable MangaTable
.innerJoin(CategoryMangaTable) .innerJoin(CategoryMangaTable)
.leftJoin(ChapterTable, { MangaTable.id }, { ChapterTable.manga }) .leftJoin(ChapterTable, { MangaTable.id }, { ChapterTable.manga })
.slice(columns = selectedColumns) .select(columns = selectedColumns)
.select { (MangaTable.inLibrary eq true) and (CategoryMangaTable.category eq categoryId) } .where { (MangaTable.inLibrary eq true) and (CategoryMangaTable.category eq categoryId) }
} }
// Join with the ChapterTable to fetch the last read chapter for each manga // Join with the ChapterTable to fetch the last read chapter for each manga
@@ -126,7 +127,8 @@ object CategoryManga {
transaction { transaction {
CategoryMangaTable CategoryMangaTable
.innerJoin(CategoryTable) .innerJoin(CategoryTable)
.select { .selectAll()
.where {
CategoryMangaTable.manga eq mangaId CategoryMangaTable.manga eq mangaId
}.orderBy(CategoryTable.order to SortOrder.ASC) }.orderBy(CategoryTable.order to SortOrder.ASC)
.map { .map {
@@ -139,7 +141,8 @@ object CategoryManga {
transaction { transaction {
CategoryMangaTable CategoryMangaTable
.innerJoin(CategoryTable) .innerJoin(CategoryTable)
.select { CategoryMangaTable.manga inList mangaIDs } .selectAll()
.where { CategoryMangaTable.manga inList mangaIDs }
.groupBy { it[CategoryMangaTable.manga] } .groupBy { it[CategoryMangaTable.manga] }
.forEach { .forEach {
val mangaId = it.key.value val mangaId = it.key.value

View File

@@ -12,11 +12,11 @@ import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.HttpSource
import eu.kanade.tachiyomi.util.chapter.ChapterRecognition import eu.kanade.tachiyomi.util.chapter.ChapterRecognition
import eu.kanade.tachiyomi.util.chapter.ChapterSanitizer.sanitize import eu.kanade.tachiyomi.util.chapter.ChapterSanitizer.sanitize
import io.github.oshai.kotlinlogging.KotlinLogging
import io.github.reactivecircus.cache4k.Cache import io.github.reactivecircus.cache4k.Cache
import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.sync.withLock
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import mu.KotlinLogging
import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.dao.id.EntityID
import org.jetbrains.exposed.sql.Op import org.jetbrains.exposed.sql.Op
import org.jetbrains.exposed.sql.SortOrder 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.batchInsert
import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.deleteWhere
import org.jetbrains.exposed.sql.insert 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.statements.BatchUpdateStatement
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update
@@ -70,7 +70,8 @@ object Chapter {
} else { } else {
transaction { transaction {
ChapterTable ChapterTable
.select { ChapterTable.manga eq mangaId } .selectAll()
.where { ChapterTable.manga eq mangaId }
.orderBy(ChapterTable.sourceOrder to SortOrder.DESC) .orderBy(ChapterTable.sourceOrder to SortOrder.DESC)
.map { .map {
ChapterTable.toDataClass(it) 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<ChapterDataClass> { private suspend fun getSourceChapters(mangaId: Int): List<ChapterDataClass> {
val chapterList = fetchChapterList(mangaId) val chapterList = fetchChapterList(mangaId)
@@ -88,7 +96,8 @@ object Chapter {
val dbChapterMap = val dbChapterMap =
transaction { transaction {
ChapterTable ChapterTable
.select { ChapterTable.manga eq mangaId } .selectAll()
.where { ChapterTable.manga eq mangaId }
.associateBy({ it[ChapterTable.url] }, { it }) .associateBy({ it[ChapterTable.url] }, { it })
} }
@@ -173,7 +182,8 @@ object Chapter {
val chaptersInDb = val chaptersInDb =
transaction { transaction {
ChapterTable ChapterTable
.select { ChapterTable.manga eq mangaId } .selectAll()
.where { ChapterTable.manga eq mangaId }
.map { ChapterTable.toDataClass(it) } .map { ChapterTable.toDataClass(it) }
.toList() .toList()
} }
@@ -533,7 +543,8 @@ object Chapter {
val mangaIds = val mangaIds =
transaction { transaction {
ChapterTable ChapterTable
.select { condition } .selectAll()
.where(condition)
.map { it[ChapterTable.manga].value } .map { it[ChapterTable.manga].value }
.toSet() .toSet()
} }
@@ -544,7 +555,8 @@ object Chapter {
fun getChaptersMetaMaps(chapterIds: List<EntityID<Int>>): Map<EntityID<Int>, Map<String, String>> = fun getChaptersMetaMaps(chapterIds: List<EntityID<Int>>): Map<EntityID<Int>, Map<String, String>> =
transaction { transaction {
ChapterMetaTable ChapterMetaTable
.select { ChapterMetaTable.ref inList chapterIds } .selectAll()
.where { ChapterMetaTable.ref inList chapterIds }
.groupBy { it[ChapterMetaTable.ref] } .groupBy { it[ChapterMetaTable.ref] }
.mapValues { it.value.associate { it[ChapterMetaTable.key] to it[ChapterMetaTable.value] } } .mapValues { it.value.associate { it[ChapterMetaTable.key] to it[ChapterMetaTable.value] } }
.withDefault { emptyMap<String, String>() } .withDefault { emptyMap<String, String>() }
@@ -553,7 +565,8 @@ object Chapter {
fun getChapterMetaMap(chapter: EntityID<Int>): Map<String, String> = fun getChapterMetaMap(chapter: EntityID<Int>): Map<String, String> =
transaction { transaction {
ChapterMetaTable ChapterMetaTable
.select { ChapterMetaTable.ref eq chapter } .selectAll()
.where { ChapterMetaTable.ref eq chapter }
.associate { it[ChapterMetaTable.key] to it[ChapterMetaTable.value] } .associate { it[ChapterMetaTable.key] to it[ChapterMetaTable.value] }
} }
@@ -566,7 +579,8 @@ object Chapter {
transaction { transaction {
val chapterId = val chapterId =
ChapterTable 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] .first()[ChapterTable.id]
.value .value
modifyChapterMeta(chapterId, key, value) modifyChapterMeta(chapterId, key, value)
@@ -581,7 +595,8 @@ object Chapter {
transaction { transaction {
val meta = val meta =
ChapterMetaTable ChapterMetaTable
.select { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) } .selectAll()
.where { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
.firstOrNull() .firstOrNull()
if (meta == null) { if (meta == null) {
@@ -605,7 +620,8 @@ object Chapter {
transaction { transaction {
val chapterId = val chapterId =
ChapterTable 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] .first()[ChapterTable.id]
.value .value
@@ -627,9 +643,11 @@ object Chapter {
transaction { transaction {
val chapterIds = val chapterIds =
ChapterTable ChapterTable
.slice(ChapterTable.manga, ChapterTable.id) .select(ChapterTable.manga, ChapterTable.id)
.select { (ChapterTable.sourceOrder inList input.chapterIndexes) and (ChapterTable.manga eq mangaId) } .where {
.map { row -> (ChapterTable.sourceOrder inList input.chapterIndexes) and
(ChapterTable.manga eq mangaId)
}.map { row ->
val chapterId = row[ChapterTable.id].value val chapterId = row[ChapterTable.id].value
ChapterDownloadHelper.delete(mangaId, chapterId) ChapterDownloadHelper.delete(mangaId, chapterId)
@@ -646,8 +664,8 @@ object Chapter {
fun deleteChapters(chapterIds: List<Int>) { fun deleteChapters(chapterIds: List<Int>) {
transaction { transaction {
ChapterTable ChapterTable
.slice(ChapterTable.manga, ChapterTable.id) .select(ChapterTable.manga, ChapterTable.id)
.select { ChapterTable.id inList chapterIds } .where { ChapterTable.id inList chapterIds }
.forEach { row -> .forEach { row ->
val chapterMangaId = row[ChapterTable.manga].value val chapterMangaId = row[ChapterTable.manga].value
val chapterId = row[ChapterTable.id].value val chapterId = row[ChapterTable.id].value
@@ -664,7 +682,8 @@ object Chapter {
paginatedFrom(pageNum) { paginatedFrom(pageNum) {
transaction { transaction {
(ChapterTable innerJoin MangaTable) (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) .orderBy(ChapterTable.fetchedAt to SortOrder.DESC)
.map { .map {
MangaChapterDataClass( MangaChapterDataClass(

View File

@@ -13,7 +13,7 @@ import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.insert 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.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update
import suwayomi.tachidesk.manga.impl.Manga.getManga import suwayomi.tachidesk.manga.impl.Manga.getManga
@@ -31,10 +31,12 @@ object Library {
transaction { transaction {
val defaultCategories = val defaultCategories =
CategoryTable CategoryTable
.select { .selectAll()
(CategoryTable.isDefault eq true) and (CategoryTable.id neq Category.DEFAULT_CATEGORY_ID) .where {
(CategoryTable.isDefault eq true) and
(CategoryTable.id neq Category.DEFAULT_CATEGORY_ID)
}.toList() }.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 }) { MangaTable.update({ MangaTable.id eq manga.id }) {
it[inLibrary] = true it[inLibrary] = true

View File

@@ -15,16 +15,16 @@ import eu.kanade.tachiyomi.source.local.LocalSource
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.model.UpdateStrategy import eu.kanade.tachiyomi.source.model.UpdateStrategy
import eu.kanade.tachiyomi.source.online.HttpSource 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 io.javalin.http.HttpStatus
import mu.KLogger
import mu.KotlinLogging
import okhttp3.CacheControl import okhttp3.CacheControl
import okhttp3.Response import okhttp3.Response
import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.SortOrder import org.jetbrains.exposed.sql.SortOrder
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.insert 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.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update
import suwayomi.tachidesk.manga.impl.MangaList.proxyThumbnailUrl import suwayomi.tachidesk.manga.impl.MangaList.proxyThumbnailUrl
@@ -72,14 +72,14 @@ object Manga {
mangaId: Int, mangaId: Int,
onlineFetch: Boolean = false, onlineFetch: Boolean = false,
): MangaDataClass { ): 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]) { return if (!onlineFetch && mangaEntry[MangaTable.initialized]) {
getMangaDataClass(mangaId, mangaEntry) getMangaDataClass(mangaId, mangaEntry)
} else { // initialize manga } else { // initialize manga
val sManga = fetchManga(mangaId) ?: return getMangaDataClass(mangaId, mangaEntry) 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( MangaDataClass(
id = mangaId, id = mangaId,
@@ -109,7 +109,7 @@ object Manga {
} }
suspend fun fetchManga(mangaId: Int): SManga? { 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 = val source =
getCatalogueSourceOrNull(mangaEntry[MangaTable.sourceReference]) getCatalogueSourceOrNull(mangaEntry[MangaTable.sourceReference])
@@ -193,22 +193,26 @@ object Manga {
return transaction { return transaction {
val unreadCount = val unreadCount =
ChapterTable ChapterTable
.select { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq false) } .selectAll()
.where { (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq false) }
.count() .count()
val downloadCount = val downloadCount =
ChapterTable ChapterTable
.select { (ChapterTable.manga eq mangaId) and (ChapterTable.isDownloaded eq true) } .selectAll()
.where { (ChapterTable.manga eq mangaId) and (ChapterTable.isDownloaded eq true) }
.count() .count()
val chapterCount = val chapterCount =
ChapterTable ChapterTable
.select { (ChapterTable.manga eq mangaId) } .selectAll()
.where { (ChapterTable.manga eq mangaId) }
.count() .count()
val lastChapterRead = val lastChapterRead =
ChapterTable ChapterTable
.select { (ChapterTable.manga eq mangaId) } .selectAll()
.where { (ChapterTable.manga eq mangaId) }
.orderBy(ChapterTable.sourceOrder to SortOrder.DESC) .orderBy(ChapterTable.sourceOrder to SortOrder.DESC)
.firstOrNull { it[ChapterTable.isRead] } .firstOrNull { it[ChapterTable.isRead] }
@@ -252,7 +256,8 @@ object Manga {
fun getMangaMetaMap(mangaId: Int): Map<String, String> = fun getMangaMetaMap(mangaId: Int): Map<String, String> =
transaction { transaction {
MangaMetaTable MangaMetaTable
.select { MangaMetaTable.ref eq mangaId } .selectAll()
.where { MangaMetaTable.ref eq mangaId }
.associate { it[MangaMetaTable.key] to it[MangaMetaTable.value] } .associate { it[MangaMetaTable.key] to it[MangaMetaTable.value] }
} }
@@ -264,7 +269,8 @@ object Manga {
transaction { transaction {
val meta = val meta =
MangaMetaTable MangaMetaTable
.select { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) } .selectAll()
.where { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) }
.firstOrNull() .firstOrNull()
if (meta == null) { if (meta == null) {
@@ -284,7 +290,7 @@ object Manga {
private suspend fun fetchThumbnailUrl(mangaId: Int): String? { private suspend fun fetchThumbnailUrl(mangaId: Int): String? {
getManga(mangaId, true) getManga(mangaId, true)
return transaction { return transaction {
MangaTable.select { MangaTable.id eq mangaId }.first() MangaTable.selectAll().where { MangaTable.id eq mangaId }.first()
}[MangaTable.thumbnail_url] }[MangaTable.thumbnail_url]
} }
@@ -335,7 +341,7 @@ object Manga {
val cacheSaveDir = applicationDirs.tempThumbnailCacheRoot val cacheSaveDir = applicationDirs.tempThumbnailCacheRoot
val fileName = mangaId.toString() 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] val sourceId = mangaEntry[MangaTable.sourceReference]
return when (val source = getCatalogueSourceOrStub(sourceId)) { return when (val source = getCatalogueSourceOrStub(sourceId)) {
@@ -376,7 +382,7 @@ object Manga {
} }
suspend fun getMangaThumbnail(mangaId: Int): Pair<InputStream, String> { suspend fun getMangaThumbnail(mangaId: Int): Pair<InputStream, String> {
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) { if (mangaEntry[MangaTable.inLibrary] && mangaEntry[MangaTable.sourceReference] != LocalSource.ID) {
return try { return try {
@@ -399,13 +405,14 @@ object Manga {
fun getLatestChapter(mangaId: Int): ChapterDataClass? = fun getLatestChapter(mangaId: Int): ChapterDataClass? =
transaction { 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) } }?.let { ChapterTable.toDataClass(it) }
fun getUnreadChapters(mangaId: Int): List<ChapterDataClass> = fun getUnreadChapters(mangaId: Int): List<ChapterDataClass> =
transaction { transaction {
ChapterTable 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) .orderBy(ChapterTable.sourceOrder to SortOrder.DESC)
.map { ChapterTable.toDataClass(it) } .map { ChapterTable.toDataClass(it) }
} }

View File

@@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.source.model.MangasPage
import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.dao.id.EntityID
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.batchInsert 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.statements.BatchUpdateStatement
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.getCatalogueSourceOrStub import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.getCatalogueSourceOrStub
@@ -49,8 +49,10 @@ object MangaList {
transaction { transaction {
val existingMangaUrlsToId = val existingMangaUrlsToId =
MangaTable MangaTable
.select { .selectAll()
(MangaTable.sourceReference eq sourceId) and (MangaTable.url inList mangas.map { it.url }) .where {
(MangaTable.sourceReference eq sourceId) and
(MangaTable.url inList mangas.map { it.url })
}.associateBy { it[MangaTable.url] } }.associateBy { it[MangaTable.url] }
val existingMangaUrls = existingMangaUrlsToId.map { it.key } val existingMangaUrls = existingMangaUrlsToId.map { it.key }
@@ -123,7 +125,7 @@ object MangaList {
val mangaList = val mangaList =
transaction { transaction {
val mangaIds = insertOrUpdate(sourceId) 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( return PagedMangaListDataClass(
mangaList, mangaList,

View File

@@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.source.online.HttpSource
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
import org.jetbrains.exposed.sql.SortOrder import org.jetbrains.exposed.sql.SortOrder
import org.jetbrains.exposed.sql.and 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.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update
import suwayomi.tachidesk.manga.impl.util.getChapterCachePath import suwayomi.tachidesk.manga.impl.util.getChapterCachePath
@@ -47,13 +47,15 @@ object Page {
index: Int, index: Int,
progressFlow: ((StateFlow<Int>) -> Unit)? = null, progressFlow: ((StateFlow<Int>) -> Unit)? = null,
): Pair<InputStream, String> { ): Pair<InputStream, String> {
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 source = getCatalogueSourceOrStub(mangaEntry[MangaTable.sourceReference])
val chapterEntry = val chapterEntry =
transaction { transaction {
ChapterTable ChapterTable
.select { .selectAll()
(ChapterTable.sourceOrder eq chapterIndex) and (ChapterTable.manga eq mangaId) .where {
(ChapterTable.sourceOrder eq chapterIndex) and
(ChapterTable.manga eq mangaId)
}.first() }.first()
} }
val chapterId = chapterEntry[ChapterTable.id].value val chapterId = chapterEntry[ChapterTable.id].value
@@ -61,7 +63,8 @@ object Page {
val pageEntry = val pageEntry =
transaction { transaction {
PageTable PageTable
.select { (PageTable.chapter eq chapterId) } .selectAll()
.where { (PageTable.chapter eq chapterId) }
.orderBy(PageTable.index to SortOrder.ASC) .orderBy(PageTable.index to SortOrder.ASC)
.limit(1, index.toLong()) .limit(1, index.toLong())
.first() .first()

View File

@@ -11,12 +11,11 @@ import androidx.preference.Preference
import androidx.preference.PreferenceScreen import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.source.ConfigurableSource import eu.kanade.tachiyomi.source.ConfigurableSource
import eu.kanade.tachiyomi.source.sourcePreferences import eu.kanade.tachiyomi.source.sourcePreferences
import io.github.oshai.kotlinlogging.KotlinLogging
import io.javalin.json.JsonMapper import io.javalin.json.JsonMapper
import io.javalin.json.fromJsonString import io.javalin.json.fromJsonString
import mu.KotlinLogging
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update
@@ -39,7 +38,7 @@ object Source {
return transaction { return transaction {
SourceTable.selectAll().mapNotNull { SourceTable.selectAll().mapNotNull {
val catalogueSource = getCatalogueSourceOrNull(it[SourceTable.id].value) ?: return@mapNotNull null 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( SourceDataClass(
it[SourceTable.id].value.toString(), 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 fun getSource(sourceId: Long): SourceDataClass? { // all the data extracted fresh form the source instance
return transaction { 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 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( SourceDataClass(
sourceId.toString(), sourceId.toString(),
@@ -160,7 +159,7 @@ object Source {
transaction { transaction {
val meta = val meta =
transaction { 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() }.firstOrNull()
if (meta == null) { if (meta == null) {

View File

@@ -10,19 +10,18 @@ package suwayomi.tachidesk.manga.impl.backup.proto
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import eu.kanade.tachiyomi.source.model.UpdateStrategy import eu.kanade.tachiyomi.source.model.UpdateStrategy
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import mu.KotlinLogging
import okio.Buffer import okio.Buffer
import okio.Sink import okio.Sink
import okio.buffer import okio.buffer
import okio.gzip import okio.gzip
import org.jetbrains.exposed.sql.Query import org.jetbrains.exposed.sql.Query
import org.jetbrains.exposed.sql.SortOrder import org.jetbrains.exposed.sql.SortOrder
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.manga.impl.CategoryManga import suwayomi.tachidesk.manga.impl.CategoryManga
@@ -175,7 +174,7 @@ object ProtoBackupExport : ProtoBackupBase() {
fun createBackup(flags: BackupFlags): InputStream { fun createBackup(flags: BackupFlags): InputStream {
// Create root object // 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 = val backup: Backup =
transaction { transaction {
@@ -224,7 +223,8 @@ object ProtoBackupExport : ProtoBackupBase() {
val chapters = val chapters =
transaction { transaction {
ChapterTable ChapterTable
.select { ChapterTable.manga eq mangaId } .selectAll()
.where { ChapterTable.manga eq mangaId }
.orderBy(ChapterTable.sourceOrder to SortOrder.DESC) .orderBy(ChapterTable.sourceOrder to SortOrder.DESC)
.map { .map {
ChapterTable.toDataClass(it) ChapterTable.toDataClass(it)
@@ -306,7 +306,7 @@ object ProtoBackupExport : ProtoBackupBase() {
.map { it[MangaTable.sourceReference] } .map { it[MangaTable.sourceReference] }
.distinct() .distinct()
.map { .map {
val sourceRow = SourceTable.select { SourceTable.id eq it }.firstOrNull() val sourceRow = SourceTable.selectAll().where { SourceTable.id eq it }.firstOrNull()
BackupSource( BackupSource(
sourceRow?.get(SourceTable.name) ?: "", sourceRow?.get(SourceTable.name) ?: "",
it, it,

View File

@@ -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 * 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/. */ * 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.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@@ -17,7 +18,6 @@ import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.sync.withLock
import mu.KotlinLogging
import okio.buffer import okio.buffer
import okio.gzip import okio.gzip
import okio.source import okio.source
@@ -25,7 +25,7 @@ import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.batchInsert import org.jetbrains.exposed.sql.batchInsert
import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.insertAndGetId 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.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update
import suwayomi.tachidesk.graphql.types.toStatus import suwayomi.tachidesk.graphql.types.toStatus
@@ -183,7 +183,8 @@ object ProtoBackupImport : ProtoBackupBase() {
backup.backupCategories.associate { backup.backupCategories.associate {
val dbCategory = val dbCategory =
CategoryTable CategoryTable
.select { CategoryTable.name eq it.name } .selectAll()
.where { CategoryTable.name eq it.name }
.firstOrNull() .firstOrNull()
val categoryId = val categoryId =
dbCategory?.let { categoryResultRow -> dbCategory?.let { categoryResultRow ->
@@ -275,7 +276,8 @@ object ProtoBackupImport : ProtoBackupBase() {
val dbManga = val dbManga =
transaction { transaction {
MangaTable 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() .firstOrNull()
} }
@@ -362,7 +364,7 @@ object ProtoBackupImport : ProtoBackupBase() {
// merge chapter data // merge chapter data
val chaptersLength = chapters.size val chaptersLength = chapters.size
val dbChapters = ChapterTable.select { ChapterTable.manga eq mangaId } val dbChapters = ChapterTable.selectAll().where { ChapterTable.manga eq mangaId }
chapters.forEach { chapter -> chapters.forEach { chapter ->
val dbChapter = dbChapters.find { it[ChapterTable.url] == chapter.url } val dbChapter = dbChapters.find { it[ChapterTable.url] == chapter.url }

View File

@@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore
import okio.buffer import okio.buffer
import okio.gzip import okio.gzip
import okio.source import okio.source
import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.manga.impl.backup.proto.models.Backup import suwayomi.tachidesk.manga.impl.backup.proto.models.Backup
import suwayomi.tachidesk.manga.impl.track.tracker.TrackerManager import suwayomi.tachidesk.manga.impl.track.tracker.TrackerManager
@@ -36,7 +36,7 @@ object ProtoBackupValidator {
val missingSources = val missingSources =
transaction { 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 = val trackers =

View File

@@ -9,14 +9,14 @@ package suwayomi.tachidesk.manga.impl.chapter
import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import mu.KLogger import io.github.oshai.kotlinlogging.KLogger
import mu.KotlinLogging import io.github.oshai.kotlinlogging.KotlinLogging
import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.batchInsert import org.jetbrains.exposed.sql.batchInsert
import org.jetbrains.exposed.sql.deleteWhere 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.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update
import suwayomi.tachidesk.manga.impl.ChapterDownloadHelper import suwayomi.tachidesk.manga.impl.ChapterDownloadHelper
@@ -98,7 +98,8 @@ private class ChapterForDownload(
optMangaId: Int? = null, optMangaId: Int? = null,
) = transaction { ) = transaction {
ChapterTable ChapterTable
.select { .selectAll()
.where {
if (optChapterId != null) { if (optChapterId != null) {
ChapterTable.id eq optChapterId ChapterTable.id eq optChapterId
} else if (optChapterIndex != null && optMangaId != null) { } else if (optChapterIndex != null && optMangaId != null) {
@@ -110,7 +111,7 @@ private class ChapterForDownload(
} }
private suspend fun fetchPageList(): List<Page> { private suspend fun fetchPageList(): List<Page> {
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 source = getCatalogueSourceOrStub(mangaEntry[MangaTable.sourceReference])
return source.getPageList( return source.getPageList(

View File

@@ -9,6 +9,7 @@ package suwayomi.tachidesk.manga.impl.download
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import io.github.oshai.kotlinlogging.KotlinLogging
import io.javalin.websocket.WsContext import io.javalin.websocket.WsContext
import io.javalin.websocket.WsMessageContext import io.javalin.websocket.WsMessageContext
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@@ -26,9 +27,8 @@ import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.sample import kotlinx.coroutines.flow.sample
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import mu.KotlinLogging
import org.jetbrains.exposed.sql.and 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.transactions.transaction
import suwayomi.tachidesk.manga.impl.download.model.DownloadChapter import suwayomi.tachidesk.manga.impl.download.model.DownloadChapter
import suwayomi.tachidesk.manga.impl.download.model.DownloadState.Downloading import suwayomi.tachidesk.manga.impl.download.model.DownloadState.Downloading
@@ -284,8 +284,8 @@ object DownloadManager {
val chapter = val chapter =
transaction { transaction {
ChapterTable ChapterTable
.slice(ChapterTable.id) .select(ChapterTable.id)
.select { ChapterTable.manga.eq(mangaId) and ChapterTable.sourceOrder.eq(chapterIndex) } .where { ChapterTable.manga.eq(mangaId) and ChapterTable.sourceOrder.eq(chapterIndex) }
.first() .first()
} }
enqueue(EnqueueInput(chapterIds = listOf(chapter[ChapterTable.id].value))) enqueue(EnqueueInput(chapterIds = listOf(chapter[ChapterTable.id].value)))
@@ -304,7 +304,8 @@ object DownloadManager {
val chapters = val chapters =
transaction { transaction {
(ChapterTable innerJoin MangaTable) (ChapterTable innerJoin MangaTable)
.select { ChapterTable.id inList input.chapterIds } .selectAll()
.where { ChapterTable.id inList input.chapterIds }
.orderBy(ChapterTable.manga) .orderBy(ChapterTable.manga)
.orderBy(ChapterTable.sourceOrder) .orderBy(ChapterTable.sourceOrder)
.toList() .toList()

View File

@@ -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 * 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/. */ * 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.CancellationException
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
@@ -15,8 +17,6 @@ import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.ensureActive import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import mu.KLogger
import mu.KotlinLogging
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update

View File

@@ -9,7 +9,7 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.sample import kotlinx.coroutines.flow.sample
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry 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 org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.manga.impl.Page import suwayomi.tachidesk.manga.impl.Page
import suwayomi.tachidesk.manga.impl.download.model.DownloadChapter import suwayomi.tachidesk.manga.impl.download.model.DownloadChapter
@@ -141,10 +141,10 @@ abstract class ChaptersFilesProvider<Type : FileType>(
createComicInfoFile( createComicInfoFile(
downloadCacheFolder.toPath(), downloadCacheFolder.toPath(),
transaction { transaction {
MangaTable.select { MangaTable.id eq mangaId }.first() MangaTable.selectAll().where { MangaTable.id eq mangaId }.first()
}, },
transaction { transaction {
ChapterTable.select { ChapterTable.id eq chapterId }.first() ChapterTable.selectAll().where { ChapterTable.id eq chapterId }.first()
}, },
) )

View File

@@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceFactory import eu.kanade.tachiyomi.source.SourceFactory
import mu.KotlinLogging import io.github.oshai.kotlinlogging.KotlinLogging
import okhttp3.CacheControl import okhttp3.CacheControl
import okio.buffer import okio.buffer
import okio.sink import okio.sink
@@ -21,7 +21,7 @@ import okio.source
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.deleteWhere
import org.jetbrains.exposed.sql.insert 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.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update
import suwayomi.tachidesk.manga.impl.extension.ExtensionsList.extensionTableAsDataClass 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 // if it's installed and we want to update, it first has to be uninstalled
val isInstalled = val isInstalled =
transaction { transaction {
ExtensionTable.select { ExtensionTable.apkName eq apkName }.firstOrNull() ExtensionTable.selectAll().where { ExtensionTable.apkName eq apkName }.firstOrNull()
}?.get(ExtensionTable.isInstalled) ?: false }?.get(ExtensionTable.isInstalled) ?: false
val fileNameWithoutType = apkName.substringBefore(".apk") val fileNameWithoutType = apkName.substringBefore(".apk")
@@ -177,7 +177,7 @@ object Extension {
// update extension info // update extension info
transaction { transaction {
if (ExtensionTable.select { ExtensionTable.pkgName eq pkgName }.firstOrNull() == null) { if (ExtensionTable.selectAll().where { ExtensionTable.pkgName eq pkgName }.firstOrNull() == null) {
ExtensionTable.insert { ExtensionTable.insert {
it[this.apkName] = apkName it[this.apkName] = apkName
it[name] = extensionName it[name] = extensionName
@@ -198,7 +198,11 @@ object Extension {
} }
val extensionId = 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 -> sources.forEach { httpSource ->
SourceTable.insert { SourceTable.insert {
@@ -293,14 +297,14 @@ object Extension {
fun uninstallExtension(pkgName: String) { fun uninstallExtension(pkgName: String) {
logger.debug("Uninstalling $pkgName") 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 fileNameWithoutType = extensionRecord[ExtensionTable.apkName].substringBefore(".apk")
val jarPath = "${applicationDirs.extensionsRoot}/$fileNameWithoutType.jar" val jarPath = "${applicationDirs.extensionsRoot}/$fileNameWithoutType.jar"
val sources = val sources =
transaction { transaction {
val extensionId = extensionRecord[ExtensionTable.id].value 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 } SourceTable.deleteWhere { SourceTable.extension eq extensionId }
@@ -349,7 +353,7 @@ object Extension {
if (apkName == "localSource") { if (apkName == "localSource") {
"" ""
} else { } 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" val cacheSaveDir = "${applicationDirs.extensionsRoot}/icon"

View File

@@ -8,9 +8,9 @@ package suwayomi.tachidesk.manga.impl.extension
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import eu.kanade.tachiyomi.source.local.LocalSource import eu.kanade.tachiyomi.source.local.LocalSource
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.sync.withLock
import mu.KotlinLogging
import org.jetbrains.exposed.dao.id.EntityID import org.jetbrains.exposed.dao.id.EntityID
import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.SqlExpressionBuilder.inList import org.jetbrains.exposed.sql.SqlExpressionBuilder.inList

View File

@@ -11,9 +11,9 @@ import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.network.awaitSuccess import eu.kanade.tachiyomi.network.awaitSuccess
import eu.kanade.tachiyomi.network.parseAs import eu.kanade.tachiyomi.network.parseAs
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json 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_MAX
import suwayomi.tachidesk.manga.impl.util.PackageTools.LIB_VERSION_MIN import suwayomi.tachidesk.manga.impl.util.PackageTools.LIB_VERSION_MIN
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy

View File

@@ -1,18 +1,18 @@
package suwayomi.tachidesk.manga.impl.track package suwayomi.tachidesk.manga.impl.track
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import mu.KotlinLogging
import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.SortOrder import org.jetbrains.exposed.sql.SortOrder
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.deleteWhere
import org.jetbrains.exposed.sql.insertAndGetId 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.transactions.transaction
import org.jetbrains.exposed.sql.update import org.jetbrains.exposed.sql.update
import suwayomi.tachidesk.manga.impl.track.tracker.DeletableTrackService import suwayomi.tachidesk.manga.impl.track.tracker.DeletableTrackService
@@ -75,7 +75,8 @@ object Track {
val recordMap = val recordMap =
transaction { transaction {
TrackRecordTable TrackRecordTable
.select { TrackRecordTable.mangaId eq mangaId } .selectAll()
.where { TrackRecordTable.mangaId eq mangaId }
.map { it.toTrackRecordDataClass() } .map { it.toTrackRecordDataClass() }
}.associateBy { it.trackerId } }.associateBy { it.trackerId }
@@ -138,7 +139,8 @@ object Track {
val track = val track =
transaction { transaction {
TrackSearchTable TrackSearchTable
.select { .selectAll()
.where {
TrackSearchTable.trackerId eq trackerId and TrackSearchTable.trackerId eq trackerId and
(TrackSearchTable.remoteId eq remoteId) (TrackSearchTable.remoteId eq remoteId)
}.first() }.first()
@@ -162,7 +164,8 @@ object Track {
val oldestChapter = val oldestChapter =
transaction { transaction {
ChapterTable ChapterTable
.select { .selectAll()
.where {
(ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq true) (ChapterTable.manga eq mangaId) and (ChapterTable.isRead eq true)
}.orderBy(ChapterTable.lastReadAt to SortOrder.ASC) }.orderBy(ChapterTable.lastReadAt to SortOrder.ASC)
.limit(1) .limit(1)
@@ -186,7 +189,7 @@ object Track {
suspend fun refresh(recordId: Int) { suspend fun refresh(recordId: Int) {
val recordDb = val recordDb =
transaction { transaction {
TrackRecordTable.select { TrackRecordTable.id eq recordId }.first() TrackRecordTable.selectAll().where { TrackRecordTable.id eq recordId }.first()
} }
val tracker = TrackerManager.getTracker(recordDb[TrackRecordTable.trackerId])!! val tracker = TrackerManager.getTracker(recordDb[TrackRecordTable.trackerId])!!
@@ -202,7 +205,7 @@ object Track {
) { ) {
val recordDb = val recordDb =
transaction { transaction {
TrackRecordTable.select { TrackRecordTable.id eq recordId }.first() TrackRecordTable.selectAll().where { TrackRecordTable.id eq recordId }.first()
} }
val tracker = TrackerManager.getTracker(recordDb[TrackRecordTable.trackerId]) val tracker = TrackerManager.getTracker(recordDb[TrackRecordTable.trackerId])
@@ -223,7 +226,7 @@ object Track {
} }
val recordDb = val recordDb =
transaction { 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])!! val tracker = TrackerManager.getTracker(recordDb[TrackRecordTable.trackerId])!!
@@ -294,7 +297,8 @@ object Track {
private fun queryMaxReadChapter(mangaId: Int): ResultRow? = private fun queryMaxReadChapter(mangaId: Int): ResultRow? =
transaction { transaction {
ChapterTable 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) .orderBy(ChapterTable.chapter_number to SortOrder.DESC)
.limit(1) .limit(1)
.firstOrNull() .firstOrNull()
@@ -307,7 +311,8 @@ object Track {
val records = val records =
transaction { transaction {
TrackRecordTable TrackRecordTable
.select { TrackRecordTable.mangaId eq mangaId } .selectAll()
.where { TrackRecordTable.mangaId eq mangaId }
.toList() .toList()
} }
@@ -365,7 +370,8 @@ object Track {
transaction { transaction {
val existingRecord = val existingRecord =
TrackRecordTable TrackRecordTable
.select { .selectAll()
.where {
(TrackRecordTable.mangaId eq track.manga_id) and (TrackRecordTable.mangaId eq track.manga_id) and
(TrackRecordTable.trackerId eq track.sync_id) (TrackRecordTable.trackerId eq track.sync_id)
}.singleOrNull() }.singleOrNull()

View File

@@ -2,7 +2,7 @@ package suwayomi.tachidesk.manga.impl.track.tracker
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import mu.KotlinLogging import io.github.oshai.kotlinlogging.KotlinLogging
import suwayomi.tachidesk.manga.impl.track.tracker.anilist.Anilist import suwayomi.tachidesk.manga.impl.track.tracker.anilist.Anilist
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get

View File

@@ -1,9 +1,9 @@
package suwayomi.tachidesk.manga.impl.track.tracker.anilist package suwayomi.tachidesk.manga.impl.track.tracker.anilist
import android.annotation.StringRes import android.annotation.StringRes
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.serialization.encodeToString import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import mu.KotlinLogging
import suwayomi.tachidesk.manga.impl.track.tracker.DeletableTrackService import suwayomi.tachidesk.manga.impl.track.tracker.DeletableTrackService
import suwayomi.tachidesk.manga.impl.track.tracker.Tracker import suwayomi.tachidesk.manga.impl.track.tracker.Tracker
import suwayomi.tachidesk.manga.impl.track.tracker.extractToken import suwayomi.tachidesk.manga.impl.track.tracker.extractToken

View File

@@ -1,9 +1,9 @@
package suwayomi.tachidesk.manga.impl.track.tracker.myanimelist package suwayomi.tachidesk.manga.impl.track.tracker.myanimelist
import android.annotation.StringRes import android.annotation.StringRes
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.serialization.encodeToString import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import mu.KotlinLogging
import suwayomi.tachidesk.manga.impl.track.tracker.DeletableTrackService import suwayomi.tachidesk.manga.impl.track.tracker.DeletableTrackService
import suwayomi.tachidesk.manga.impl.track.tracker.Tracker import suwayomi.tachidesk.manga.impl.track.tracker.Tracker
import suwayomi.tachidesk.manga.impl.track.tracker.extractToken import suwayomi.tachidesk.manga.impl.track.tracker.extractToken

View File

@@ -3,6 +3,7 @@ package suwayomi.tachidesk.manga.impl.update
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import eu.kanade.tachiyomi.source.model.UpdateStrategy import eu.kanade.tachiyomi.source.model.UpdateStrategy
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.DelicateCoroutinesApi
@@ -27,7 +28,6 @@ import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Semaphore import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.sync.withPermit import kotlinx.coroutines.sync.withPermit
import mu.KotlinLogging
import suwayomi.tachidesk.manga.impl.Category import suwayomi.tachidesk.manga.impl.Category
import suwayomi.tachidesk.manga.impl.CategoryManga import suwayomi.tachidesk.manga.impl.CategoryManga
import suwayomi.tachidesk.manga.impl.Chapter import suwayomi.tachidesk.manga.impl.Chapter

View File

@@ -1,5 +1,6 @@
package suwayomi.tachidesk.manga.impl.update package suwayomi.tachidesk.manga.impl.update
import io.github.oshai.kotlinlogging.KotlinLogging
import io.javalin.websocket.WsContext import io.javalin.websocket.WsContext
import io.javalin.websocket.WsMessageContext import io.javalin.websocket.WsMessageContext
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@@ -8,7 +9,6 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import mu.KotlinLogging
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
object UpdaterSocket : Websocket<UpdateStatus>() { object UpdaterSocket : Websocket<UpdateStatus>() {

View File

@@ -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 * 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/. */ * 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.ClassReader
import org.objectweb.asm.ClassVisitor import org.objectweb.asm.ClassVisitor
import org.objectweb.asm.ClassWriter import org.objectweb.asm.ClassWriter

View File

@@ -8,7 +8,7 @@ package suwayomi.tachidesk.manga.impl.util
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import org.jetbrains.exposed.sql.ResultRow 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 org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource
import suwayomi.tachidesk.manga.model.table.ChapterTable import suwayomi.tachidesk.manga.model.table.ChapterTable
@@ -33,7 +33,7 @@ private fun getChapterDir(
mangaId: Int, mangaId: Int,
chapterId: Int, chapterId: Int,
): String { ): String {
val chapterEntry = transaction { ChapterTable.select { ChapterTable.id eq chapterId }.first() } val chapterEntry = transaction { ChapterTable.selectAll().where { ChapterTable.id eq chapterId }.first() }
val chapterDir = val chapterDir =
SafePath.buildValidFilename( 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() }

View File

@@ -6,7 +6,7 @@ import eu.kanade.tachiyomi.source.local.metadata.ComicInfoPublishingStatus
import nl.adaptivity.xmlutil.serialization.XML import nl.adaptivity.xmlutil.serialization.XML
import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.SortOrder 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 org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
import suwayomi.tachidesk.manga.model.table.CategoryTable import suwayomi.tachidesk.manga.model.table.CategoryTable
@@ -77,7 +77,8 @@ fun createComicInfoFile(
transaction { transaction {
CategoryMangaTable CategoryMangaTable
.innerJoin(CategoryTable) .innerJoin(CategoryTable)
.select { .selectAll()
.where {
CategoryMangaTable.manga eq manga[MangaTable.id] CategoryMangaTable.manga eq manga[MangaTable.id]
}.orderBy(CategoryTable.order to SortOrder.ASC) }.orderBy(CategoryTable.order to SortOrder.ASC)
.map { .map {

View File

@@ -14,7 +14,7 @@ import com.googlecode.d2j.dex.Dex2jar
import com.googlecode.d2j.reader.MultiDexFileReader import com.googlecode.d2j.reader.MultiDexFileReader
import com.googlecode.dex2jar.tools.BaksmaliBaseDexExceptionHandler import com.googlecode.dex2jar.tools.BaksmaliBaseDexExceptionHandler
import eu.kanade.tachiyomi.util.lang.Hash 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.ApkFile
import net.dongliu.apk.parser.ApkParsers import net.dongliu.apk.parser.ApkParsers
import org.w3c.dom.Element import org.w3c.dom.Element

View File

@@ -11,8 +11,8 @@ import eu.kanade.tachiyomi.source.CatalogueSource
import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceFactory import eu.kanade.tachiyomi.source.SourceFactory
import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.HttpSource
import mu.KotlinLogging import io.github.oshai.kotlinlogging.KotlinLogging
import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.manga.impl.util.PackageTools.loadExtensionSources import suwayomi.tachidesk.manga.impl.util.PackageTools.loadExtensionSources
import suwayomi.tachidesk.manga.model.table.ExtensionTable import suwayomi.tachidesk.manga.model.table.ExtensionTable
@@ -35,13 +35,13 @@ object GetCatalogueSource {
val sourceRecord = val sourceRecord =
transaction { transaction {
SourceTable.select { SourceTable.id eq sourceId }.firstOrNull() SourceTable.selectAll().where { SourceTable.id eq sourceId }.firstOrNull()
} ?: return null } ?: return null
val extensionId = sourceRecord[SourceTable.extension] val extensionId = sourceRecord[SourceTable.extension]
val extensionRecord = val extensionRecord =
transaction { transaction {
ExtensionTable.select { ExtensionTable.id eq extensionId }.first() ExtensionTable.selectAll().where { ExtensionTable.id eq extensionId }.first()
} }
val apkName = extensionRecord[ExtensionTable.apkName] val apkName = extensionRecord[ExtensionTable.apkName]

View File

@@ -10,7 +10,7 @@ package suwayomi.tachidesk.manga.model.table
import org.jetbrains.exposed.dao.id.IntIdTable import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.ReferenceOption import org.jetbrains.exposed.sql.ReferenceOption
import org.jetbrains.exposed.sql.ResultRow 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 org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.manga.impl.Chapter.getChapterMetaMap import suwayomi.tachidesk.manga.impl.Chapter.getChapterMetaMap
import suwayomi.tachidesk.manga.model.dataclass.ChapterDataClass import suwayomi.tachidesk.manga.model.dataclass.ChapterDataClass
@@ -59,6 +59,13 @@ fun ChapterTable.toDataClass(chapterEntry: ResultRow) =
realUrl = chapterEntry[realUrl], realUrl = chapterEntry[realUrl],
downloaded = chapterEntry[isDownloaded], downloaded = chapterEntry[isDownloaded],
pageCount = chapterEntry[pageCount], 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]), meta = getChapterMetaMap(chapterEntry[id]),
) )

View File

@@ -12,7 +12,7 @@ import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.batchInsert 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.statements.BatchUpdateStatement
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import suwayomi.tachidesk.manga.impl.track.tracker.model.TrackSearch import suwayomi.tachidesk.manga.impl.track.tracker.model.TrackSearch
@@ -38,8 +38,10 @@ fun List<TrackSearch>.insertAll(): List<ResultRow> {
val existing = val existing =
transaction { transaction {
TrackSearchTable TrackSearchTable
.select { .selectAll()
TrackSearchTable.trackerId inList trackerIds and (TrackSearchTable.remoteId inList remoteIds) .where {
TrackSearchTable.trackerId inList trackerIds and
(TrackSearchTable.remoteId inList remoteIds)
}.toList() }.toList()
} }
@@ -95,7 +97,7 @@ fun List<TrackSearch>.insertAll(): List<ResultRow> {
toUpdate toUpdate
?.mapNotNull { it.first } ?.mapNotNull { it.first }
?.let { ids -> ?.let { ids ->
transaction { TrackSearchTable.select { TrackSearchTable.id inList ids }.toList() } transaction { TrackSearchTable.selectAll().where { TrackSearchTable.id inList ids }.toList() }
}.orEmpty() }.orEmpty()
(insertedRows + updatedRows) (insertedRows + updatedRows)

View File

@@ -7,6 +7,7 @@ package suwayomi.tachidesk.server
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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.Javalin
import io.javalin.apibuilder.ApiBuilder.path import io.javalin.apibuilder.ApiBuilder.path
import io.javalin.http.UnauthorizedResponse import io.javalin.http.UnauthorizedResponse
@@ -17,7 +18,6 @@ import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.future.future import kotlinx.coroutines.future.future
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import mu.KotlinLogging
import org.eclipse.jetty.server.ServerConnector import org.eclipse.jetty.server.ServerConnector
import suwayomi.tachidesk.global.GlobalAPI import suwayomi.tachidesk.global.GlobalAPI
import suwayomi.tachidesk.graphql.GraphQL import suwayomi.tachidesk.graphql.GraphQL

View File

@@ -2,7 +2,7 @@ package suwayomi.tachidesk.server
import android.app.Application import android.app.Application
import android.content.Context import android.content.Context
import mu.KotlinLogging import io.github.oshai.kotlinlogging.KotlinLogging
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import java.io.File import java.io.File

View File

@@ -13,12 +13,12 @@ import eu.kanade.tachiyomi.App
import eu.kanade.tachiyomi.createAppModule import eu.kanade.tachiyomi.createAppModule
import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.source.local.LocalSource import eu.kanade.tachiyomi.source.local.LocalSource
import io.github.oshai.kotlinlogging.KotlinLogging
import io.javalin.json.JavalinJackson import io.javalin.json.JavalinJackson
import io.javalin.json.JsonMapper import io.javalin.json.JsonMapper
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.distinctUntilChanged
import mu.KotlinLogging
import org.bouncycastle.jce.provider.BouncyCastleProvider import org.bouncycastle.jce.provider.BouncyCastleProvider
import org.koin.core.context.startKoin import org.koin.core.context.startKoin
import org.koin.core.module.Module import org.koin.core.module.Module

View File

@@ -9,9 +9,10 @@ package suwayomi.tachidesk.server.database
import de.neonew.exposed.migrations.loadMigrationsFrom import de.neonew.exposed.migrations.loadMigrationsFrom
import de.neonew.exposed.migrations.runMigrations 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.Database
import org.jetbrains.exposed.sql.DatabaseConfig import org.jetbrains.exposed.sql.DatabaseConfig
import org.jetbrains.exposed.sql.ExperimentalKeywordApi
import suwayomi.tachidesk.server.ApplicationDirs import suwayomi.tachidesk.server.ApplicationDirs
import suwayomi.tachidesk.server.ServerConfig import suwayomi.tachidesk.server.ServerConfig
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
@@ -26,6 +27,8 @@ object DBManager {
databaseConfig = databaseConfig =
DatabaseConfig { DatabaseConfig {
useNestedTransactions = true useNestedTransactions = true
@OptIn(ExperimentalKeywordApi::class)
preserveKeywordCasing = false
}, },
) )
} }

View File

@@ -7,7 +7,7 @@ package suwayomi.tachidesk.server.util
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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 import kotlin.system.exitProcess
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}

View File

@@ -7,9 +7,9 @@ package suwayomi.tachidesk.server.util
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * 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.JsonMapper
import io.javalin.json.fromJsonString import io.javalin.json.fromJsonString
import mu.KotlinLogging
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request.Builder import okhttp3.Request.Builder
import suwayomi.tachidesk.global.impl.AboutDataClass import suwayomi.tachidesk.global.impl.AboutDataClass

View File

@@ -8,7 +8,7 @@ package suwayomi.tachidesk.server.util
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import dorkbox.desktop.Desktop import dorkbox.desktop.Desktop
import mu.KotlinLogging import io.github.oshai.kotlinlogging.KotlinLogging
import suwayomi.tachidesk.server.serverConfig import suwayomi.tachidesk.server.serverConfig
object Browser { object Browser {

View File

@@ -10,7 +10,7 @@ package suwayomi.tachidesk.server.util
import dorkbox.systemTray.MenuItem import dorkbox.systemTray.MenuItem
import dorkbox.systemTray.SystemTray import dorkbox.systemTray.SystemTray
import dorkbox.util.CacheUtil import dorkbox.util.CacheUtil
import mu.KotlinLogging import io.github.oshai.kotlinlogging.KotlinLogging
import suwayomi.tachidesk.server.ServerConfig import suwayomi.tachidesk.server.ServerConfig
import suwayomi.tachidesk.server.generated.BuildConfig import suwayomi.tachidesk.server.generated.BuildConfig
import suwayomi.tachidesk.server.serverConfig import suwayomi.tachidesk.server.serverConfig

View File

@@ -12,6 +12,8 @@ import android.content.Context
import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.GET
import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.network.awaitSuccess 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.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@@ -32,8 +34,6 @@ import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonArray import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive import kotlinx.serialization.json.jsonPrimitive
import mu.KLogger
import mu.KotlinLogging
import net.lingala.zip4j.ZipFile import net.lingala.zip4j.ZipFile
import suwayomi.tachidesk.graphql.types.AboutWebUI import suwayomi.tachidesk.graphql.types.AboutWebUI
import suwayomi.tachidesk.graphql.types.UpdateState import suwayomi.tachidesk.graphql.types.UpdateState

View File

@@ -5,10 +5,10 @@ import com.cronutils.model.CronType.CRON4J
import com.cronutils.model.definition.CronDefinitionBuilder import com.cronutils.model.definition.CronDefinitionBuilder
import com.cronutils.model.time.ExecutionTime import com.cronutils.model.time.ExecutionTime
import com.cronutils.parser.CronParser import com.cronutils.parser.CronParser
import io.github.oshai.kotlinlogging.KotlinLogging
import it.sauronsoftware.cron4j.Scheduler import it.sauronsoftware.cron4j.Scheduler
import it.sauronsoftware.cron4j.Task import it.sauronsoftware.cron4j.Task
import it.sauronsoftware.cron4j.TaskExecutionContext import it.sauronsoftware.cron4j.TaskExecutionContext
import mu.KotlinLogging
import java.time.ZonedDateTime import java.time.ZonedDateTime
import java.util.Date import java.util.Date
import java.util.PriorityQueue import java.util.PriorityQueue

View File

@@ -1,9 +1,9 @@
package masstest package masstest
import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.HttpSource
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import mu.KotlinLogging
import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance

View File

@@ -10,13 +10,13 @@ package masstest
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.HttpSource
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.sync.Semaphore import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.sync.withPermit import kotlinx.coroutines.sync.withPermit
import mu.KotlinLogging
import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance import org.junit.jupiter.api.TestInstance

View File

@@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.App
import eu.kanade.tachiyomi.createAppModule import eu.kanade.tachiyomi.createAppModule
import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.source.local.LocalSource import eu.kanade.tachiyomi.source.local.LocalSource
import mu.KotlinLogging import io.github.oshai.kotlinlogging.KotlinLogging
import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.Database
import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.BeforeAll
import org.koin.core.context.startKoin import org.koin.core.context.startKoin

View File

@@ -9,7 +9,7 @@ package suwayomi.tachidesk.test
import ch.qos.logback.classic.Level import ch.qos.logback.classic.Level
import eu.kanade.tachiyomi.source.model.SManga 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.dao.id.IdTable
import org.jetbrains.exposed.sql.batchInsert import org.jetbrains.exposed.sql.batchInsert
import org.jetbrains.exposed.sql.deleteAll import org.jetbrains.exposed.sql.deleteAll