mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-06-30 17:34:39 -05:00
Minor cleanup
This commit is contained in:
@@ -64,8 +64,8 @@ dependencies {
|
|||||||
// implementation(fileTree("lib/"))
|
// implementation(fileTree("lib/"))
|
||||||
implementation(kotlin("script-runtime"))
|
implementation(kotlin("script-runtime"))
|
||||||
|
|
||||||
implementation("com.expediagroup:graphql-kotlin-server:6.3.0")
|
implementation("com.expediagroup:graphql-kotlin-server:6.4.0")
|
||||||
implementation("com.expediagroup:graphql-kotlin-schema-generator:6.3.0")
|
implementation("com.expediagroup:graphql-kotlin-schema-generator:6.4.0")
|
||||||
implementation("com.graphql-java:graphql-java-extended-scalars:20.0")
|
implementation("com.graphql-java:graphql-java-extended-scalars:20.0")
|
||||||
|
|
||||||
testImplementation(libs.mockk)
|
testImplementation(libs.mockk)
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ import org.jetbrains.exposed.sql.transactions.transaction
|
|||||||
import suwayomi.tachidesk.graphql.types.CategoryType
|
import suwayomi.tachidesk.graphql.types.CategoryType
|
||||||
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
|
||||||
import java.util.concurrent.CompletableFuture
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
|
|
||||||
class CategoryDataLoader : KotlinDataLoader<Int, CategoryType> {
|
class CategoryDataLoader : KotlinDataLoader<Int, CategoryType> {
|
||||||
override val dataLoaderName = "CategoryDataLoader"
|
override val dataLoaderName = "CategoryDataLoader"
|
||||||
override fun getDataLoader(): DataLoader<Int, CategoryType> = DataLoaderFactory.newDataLoader<Int, CategoryType> { ids ->
|
override fun getDataLoader(): DataLoader<Int, CategoryType> = DataLoaderFactory.newDataLoader<Int, CategoryType> { ids ->
|
||||||
CompletableFuture.supplyAsync {
|
future {
|
||||||
transaction {
|
transaction {
|
||||||
addLogger(StdOutSqlLogger)
|
addLogger(StdOutSqlLogger)
|
||||||
CategoryTable.select { CategoryTable.id inList ids }
|
CategoryTable.select { CategoryTable.id inList ids }
|
||||||
@@ -35,10 +35,11 @@ class CategoryDataLoader : KotlinDataLoader<Int, CategoryType> {
|
|||||||
class CategoriesForMangaDataLoader : KotlinDataLoader<Int, List<CategoryType>> {
|
class CategoriesForMangaDataLoader : KotlinDataLoader<Int, List<CategoryType>> {
|
||||||
override val dataLoaderName = "CategoriesForMangaDataLoader"
|
override val dataLoaderName = "CategoriesForMangaDataLoader"
|
||||||
override fun getDataLoader(): DataLoader<Int, List<CategoryType>> = DataLoaderFactory.newDataLoader<Int, List<CategoryType>> { ids ->
|
override fun getDataLoader(): DataLoader<Int, List<CategoryType>> = DataLoaderFactory.newDataLoader<Int, List<CategoryType>> { ids ->
|
||||||
CompletableFuture.supplyAsync {
|
future {
|
||||||
transaction {
|
transaction {
|
||||||
addLogger(StdOutSqlLogger)
|
addLogger(StdOutSqlLogger)
|
||||||
val itemsByRef = CategoryMangaTable.innerJoin(CategoryTable).select { CategoryMangaTable.manga inList ids }
|
val itemsByRef = CategoryMangaTable.innerJoin(CategoryTable)
|
||||||
|
.select { CategoryMangaTable.manga inList ids }
|
||||||
.map { Pair(it[CategoryMangaTable.manga].value, CategoryType(it)) }
|
.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 } }
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ import org.jetbrains.exposed.sql.select
|
|||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
import suwayomi.tachidesk.graphql.types.ChapterType
|
import suwayomi.tachidesk.graphql.types.ChapterType
|
||||||
import suwayomi.tachidesk.manga.model.table.ChapterTable
|
import suwayomi.tachidesk.manga.model.table.ChapterTable
|
||||||
import java.util.concurrent.CompletableFuture
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
|
|
||||||
class ChapterDataLoader : KotlinDataLoader<Int, ChapterType> {
|
class ChapterDataLoader : KotlinDataLoader<Int, ChapterType> {
|
||||||
override val dataLoaderName = "ChapterDataLoader"
|
override val dataLoaderName = "ChapterDataLoader"
|
||||||
override fun getDataLoader(): DataLoader<Int, ChapterType> = DataLoaderFactory.newDataLoader<Int, ChapterType> { ids ->
|
override fun getDataLoader(): DataLoader<Int, ChapterType> = DataLoaderFactory.newDataLoader<Int, ChapterType> { ids ->
|
||||||
CompletableFuture.supplyAsync {
|
future {
|
||||||
transaction {
|
transaction {
|
||||||
addLogger(StdOutSqlLogger)
|
addLogger(StdOutSqlLogger)
|
||||||
ChapterTable.select { ChapterTable.id inList ids }
|
ChapterTable.select { ChapterTable.id inList ids }
|
||||||
@@ -34,7 +34,7 @@ class ChapterDataLoader : KotlinDataLoader<Int, ChapterType> {
|
|||||||
class ChaptersForMangaDataLoader : KotlinDataLoader<Int, List<ChapterType>> {
|
class ChaptersForMangaDataLoader : KotlinDataLoader<Int, List<ChapterType>> {
|
||||||
override val dataLoaderName = "ChaptersForMangaDataLoader"
|
override val dataLoaderName = "ChaptersForMangaDataLoader"
|
||||||
override fun getDataLoader(): DataLoader<Int, List<ChapterType>> = DataLoaderFactory.newDataLoader<Int, List<ChapterType>> { ids ->
|
override fun getDataLoader(): DataLoader<Int, List<ChapterType>> = DataLoaderFactory.newDataLoader<Int, List<ChapterType>> { ids ->
|
||||||
CompletableFuture.supplyAsync {
|
future {
|
||||||
transaction {
|
transaction {
|
||||||
addLogger(StdOutSqlLogger)
|
addLogger(StdOutSqlLogger)
|
||||||
val chaptersByMangaId = ChapterTable.select { ChapterTable.manga inList ids }
|
val chaptersByMangaId = ChapterTable.select { ChapterTable.manga inList ids }
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ import org.jetbrains.exposed.sql.transactions.transaction
|
|||||||
import suwayomi.tachidesk.graphql.types.MangaType
|
import suwayomi.tachidesk.graphql.types.MangaType
|
||||||
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
|
import suwayomi.tachidesk.manga.model.table.CategoryMangaTable
|
||||||
import suwayomi.tachidesk.manga.model.table.MangaTable
|
import suwayomi.tachidesk.manga.model.table.MangaTable
|
||||||
import java.util.concurrent.CompletableFuture
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
|
|
||||||
class MangaDataLoader : KotlinDataLoader<Int, MangaType> {
|
class MangaDataLoader : KotlinDataLoader<Int, MangaType> {
|
||||||
override val dataLoaderName = "MangaDataLoader"
|
override val dataLoaderName = "MangaDataLoader"
|
||||||
override fun getDataLoader(): DataLoader<Int, MangaType> = DataLoaderFactory.newDataLoader<Int, MangaType> { ids ->
|
override fun getDataLoader(): DataLoader<Int, MangaType> = DataLoaderFactory.newDataLoader<Int, MangaType> { ids ->
|
||||||
CompletableFuture.supplyAsync {
|
future {
|
||||||
transaction {
|
transaction {
|
||||||
addLogger(StdOutSqlLogger)
|
addLogger(StdOutSqlLogger)
|
||||||
MangaTable.select { MangaTable.id inList ids }
|
MangaTable.select { MangaTable.id inList ids }
|
||||||
@@ -36,7 +36,7 @@ class MangaDataLoader : KotlinDataLoader<Int, MangaType> {
|
|||||||
class MangaForCategoryDataLoader : KotlinDataLoader<Int, List<MangaType>> {
|
class MangaForCategoryDataLoader : KotlinDataLoader<Int, List<MangaType>> {
|
||||||
override val dataLoaderName = "MangaForCategoryDataLoader"
|
override val dataLoaderName = "MangaForCategoryDataLoader"
|
||||||
override fun getDataLoader(): DataLoader<Int, List<MangaType>> = DataLoaderFactory.newDataLoader<Int, List<MangaType>> { ids ->
|
override fun getDataLoader(): DataLoader<Int, List<MangaType>> = DataLoaderFactory.newDataLoader<Int, List<MangaType>> { ids ->
|
||||||
CompletableFuture.supplyAsync {
|
future {
|
||||||
transaction {
|
transaction {
|
||||||
addLogger(StdOutSqlLogger)
|
addLogger(StdOutSqlLogger)
|
||||||
val itemsByRef = CategoryMangaTable.innerJoin(MangaTable).select { CategoryMangaTable.category inList ids }
|
val itemsByRef = CategoryMangaTable.innerJoin(MangaTable).select { CategoryMangaTable.category inList ids }
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ import suwayomi.tachidesk.graphql.types.MangaMetaItem
|
|||||||
import suwayomi.tachidesk.graphql.types.MetaType
|
import suwayomi.tachidesk.graphql.types.MetaType
|
||||||
import suwayomi.tachidesk.manga.model.table.ChapterMetaTable
|
import suwayomi.tachidesk.manga.model.table.ChapterMetaTable
|
||||||
import suwayomi.tachidesk.manga.model.table.MangaMetaTable
|
import suwayomi.tachidesk.manga.model.table.MangaMetaTable
|
||||||
import java.util.concurrent.CompletableFuture
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
|
|
||||||
class ChapterMetaDataLoader : KotlinDataLoader<Int, MetaType> {
|
class ChapterMetaDataLoader : KotlinDataLoader<Int, MetaType> {
|
||||||
override val dataLoaderName = "ChapterMetaDataLoader"
|
override val dataLoaderName = "ChapterMetaDataLoader"
|
||||||
override fun getDataLoader(): DataLoader<Int, MetaType> = DataLoaderFactory.newDataLoader<Int, MetaType> { ids ->
|
override fun getDataLoader(): DataLoader<Int, MetaType> = DataLoaderFactory.newDataLoader<Int, MetaType> { ids ->
|
||||||
CompletableFuture.supplyAsync {
|
future {
|
||||||
transaction {
|
transaction {
|
||||||
addLogger(StdOutSqlLogger)
|
addLogger(StdOutSqlLogger)
|
||||||
val metasByRefId = ChapterMetaTable.select { ChapterMetaTable.ref inList ids }
|
val metasByRefId = ChapterMetaTable.select { ChapterMetaTable.ref inList ids }
|
||||||
@@ -33,7 +33,7 @@ class ChapterMetaDataLoader : KotlinDataLoader<Int, MetaType> {
|
|||||||
class MangaMetaDataLoader : KotlinDataLoader<Int, MetaType> {
|
class MangaMetaDataLoader : KotlinDataLoader<Int, MetaType> {
|
||||||
override val dataLoaderName = "MangaMetaDataLoader"
|
override val dataLoaderName = "MangaMetaDataLoader"
|
||||||
override fun getDataLoader(): DataLoader<Int, MetaType> = DataLoaderFactory.newDataLoader<Int, MetaType> { ids ->
|
override fun getDataLoader(): DataLoader<Int, MetaType> = DataLoaderFactory.newDataLoader<Int, MetaType> { ids ->
|
||||||
CompletableFuture.supplyAsync {
|
future {
|
||||||
transaction {
|
transaction {
|
||||||
addLogger(StdOutSqlLogger)
|
addLogger(StdOutSqlLogger)
|
||||||
val metasByRefId = MangaMetaTable.select { MangaMetaTable.ref inList ids }
|
val metasByRefId = MangaMetaTable.select { MangaMetaTable.ref inList ids }
|
||||||
@@ -48,7 +48,7 @@ class MangaMetaDataLoader : KotlinDataLoader<Int, MetaType> {
|
|||||||
class CategoryMetaDataLoader : KotlinDataLoader<Int, MetaType> {
|
class CategoryMetaDataLoader : KotlinDataLoader<Int, MetaType> {
|
||||||
override val dataLoaderName = "CategoryMetaDataLoader"
|
override val dataLoaderName = "CategoryMetaDataLoader"
|
||||||
override fun getDataLoader(): DataLoader<Int, MetaType> = DataLoaderFactory.newDataLoader<Int, MetaType> { ids ->
|
override fun getDataLoader(): DataLoader<Int, MetaType> = DataLoaderFactory.newDataLoader<Int, MetaType> { ids ->
|
||||||
CompletableFuture.supplyAsync {
|
future {
|
||||||
transaction {
|
transaction {
|
||||||
addLogger(StdOutSqlLogger)
|
addLogger(StdOutSqlLogger)
|
||||||
val metasByRefId = MangaMetaTable.select { MangaMetaTable.ref inList ids }
|
val metasByRefId = MangaMetaTable.select { MangaMetaTable.ref inList ids }
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import kotlinx.coroutines.flow.onStart
|
|||||||
import kotlinx.coroutines.flow.sample
|
import kotlinx.coroutines.flow.sample
|
||||||
import kotlinx.coroutines.job
|
import kotlinx.coroutines.job
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.slf4j.LoggerFactory
|
import mu.KotlinLogging
|
||||||
import suwayomi.tachidesk.graphql.server.TachideskGraphQLContextFactory
|
import suwayomi.tachidesk.graphql.server.TachideskGraphQLContextFactory
|
||||||
import suwayomi.tachidesk.graphql.server.subscriptions.SubscriptionOperationMessage.ClientMessages.*
|
import suwayomi.tachidesk.graphql.server.subscriptions.SubscriptionOperationMessage.ClientMessages.*
|
||||||
import suwayomi.tachidesk.graphql.server.subscriptions.SubscriptionOperationMessage.ServerMessages.*
|
import suwayomi.tachidesk.graphql.server.subscriptions.SubscriptionOperationMessage.ServerMessages.*
|
||||||
@@ -43,15 +43,14 @@ class ApolloSubscriptionProtocolHandler(
|
|||||||
private val objectMapper: ObjectMapper
|
private val objectMapper: ObjectMapper
|
||||||
) {
|
) {
|
||||||
private val sessionState = ApolloSubscriptionSessionState()
|
private val sessionState = ApolloSubscriptionSessionState()
|
||||||
private val logger = LoggerFactory.getLogger(ApolloSubscriptionProtocolHandler::class.java)
|
private val logger = KotlinLogging.logger {}
|
||||||
private val keepAliveMessage = SubscriptionOperationMessage(type = GQL_CONNECTION_KEEP_ALIVE.type)
|
private val keepAliveMessage = SubscriptionOperationMessage(type = GQL_CONNECTION_KEEP_ALIVE.type)
|
||||||
private val basicConnectionErrorMessage = SubscriptionOperationMessage(type = GQL_CONNECTION_ERROR.type)
|
private val basicConnectionErrorMessage = SubscriptionOperationMessage(type = GQL_CONNECTION_ERROR.type)
|
||||||
private val acknowledgeMessage = SubscriptionOperationMessage(GQL_CONNECTION_ACK.type)
|
private val acknowledgeMessage = SubscriptionOperationMessage(GQL_CONNECTION_ACK.type)
|
||||||
|
|
||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
|
||||||
fun handleMessage(context: WsMessageContext): Flow<SubscriptionOperationMessage> {
|
fun handleMessage(context: WsMessageContext): Flow<SubscriptionOperationMessage> {
|
||||||
val operationMessage = convertToMessageOrNull(context.message()) ?: return flowOf(basicConnectionErrorMessage)
|
val operationMessage = convertToMessageOrNull(context.message()) ?: return flowOf(basicConnectionErrorMessage)
|
||||||
logger.debug("GraphQL subscription client message, sessionId=${context.sessionId} operationMessage=$operationMessage")
|
logger.debug { "GraphQL subscription client message, sessionId=${context.sessionId} operationMessage=$operationMessage" }
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
when (operationMessage.type) {
|
when (operationMessage.type) {
|
||||||
@@ -70,7 +69,6 @@ class ApolloSubscriptionProtocolHandler(
|
|||||||
onDisconnect(context)
|
onDisconnect(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
|
||||||
private fun convertToMessageOrNull(payload: String): SubscriptionOperationMessage? {
|
private fun convertToMessageOrNull(payload: String): SubscriptionOperationMessage? {
|
||||||
return try {
|
return try {
|
||||||
objectMapper.readValue(payload)
|
objectMapper.readValue(payload)
|
||||||
|
|||||||
Reference in New Issue
Block a user