diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/UpdatesQuery.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/UpdatesQuery.kt deleted file mode 100644 index 949bb544b..000000000 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/UpdatesQuery.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) Contributors to the Suwayomi project - * - * This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -package suwayomi.tachidesk.graphql.queries - -import org.jetbrains.exposed.sql.SortOrder -import org.jetbrains.exposed.sql.and -import org.jetbrains.exposed.sql.select -import org.jetbrains.exposed.sql.transactions.transaction -import suwayomi.tachidesk.graphql.types.UpdatesNodeList -import suwayomi.tachidesk.graphql.types.UpdatesNodeList.Companion.toNodeList -import suwayomi.tachidesk.graphql.types.UpdatesType -import suwayomi.tachidesk.manga.model.dataclass.PaginationFactor -import suwayomi.tachidesk.manga.model.table.ChapterTable -import suwayomi.tachidesk.manga.model.table.MangaTable - -/** - * TODO Queries - * - Maybe replace with a chapter query with a sort - * - * TODO Mutations - * - Update the library - * - Update a category - * - Reset updater - * - */ -class UpdatesQuery { - data class UpdatesQueryInput( - val page: Int - ) - - fun updates(input: UpdatesQueryInput): UpdatesNodeList { - val results = transaction { - ChapterTable.innerJoin(MangaTable) - .select { (MangaTable.inLibrary eq true) and (ChapterTable.fetchedAt greater MangaTable.inLibraryAt) } - .orderBy(ChapterTable.fetchedAt to SortOrder.DESC) - .limit(PaginationFactor, (input.page - 1L) * PaginationFactor) - .map { - UpdatesType(it) - } - } - - return results.toNodeList() // todo paged - } -} diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TachideskGraphQLSchema.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TachideskGraphQLSchema.kt index 292aa0160..dbefa8513 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TachideskGraphQLSchema.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TachideskGraphQLSchema.kt @@ -19,7 +19,6 @@ import suwayomi.tachidesk.graphql.queries.ExtensionQuery import suwayomi.tachidesk.graphql.queries.MangaQuery import suwayomi.tachidesk.graphql.queries.MetaQuery import suwayomi.tachidesk.graphql.queries.SourceQuery -import suwayomi.tachidesk.graphql.queries.UpdatesQuery import suwayomi.tachidesk.graphql.server.primitives.Cursor import suwayomi.tachidesk.graphql.server.primitives.GraphQLCursor import suwayomi.tachidesk.graphql.server.primitives.GraphQLLongAsString @@ -47,8 +46,7 @@ val schema = toSchema( TopLevelObject(CategoryQuery()), TopLevelObject(SourceQuery()), TopLevelObject(ExtensionQuery()), - TopLevelObject(MetaQuery()), - TopLevelObject(UpdatesQuery()) + TopLevelObject(MetaQuery()) ), mutations = listOf( TopLevelObject(ChapterMutation()) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/UpdatesType.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/UpdatesType.kt deleted file mode 100644 index 7260e5a28..000000000 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/UpdatesType.kt +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) Contributors to the Suwayomi project - * - * This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -package suwayomi.tachidesk.graphql.types - -import org.jetbrains.exposed.sql.ResultRow -import suwayomi.tachidesk.graphql.server.primitives.Cursor -import suwayomi.tachidesk.graphql.server.primitives.Edge -import suwayomi.tachidesk.graphql.server.primitives.Node -import suwayomi.tachidesk.graphql.server.primitives.NodeList -import suwayomi.tachidesk.graphql.server.primitives.PageInfo - -class UpdatesType( - val manga: MangaType, - val chapter: ChapterType -) : Node { - constructor(row: ResultRow) : this( - manga = MangaType(row), - chapter = ChapterType(row) - ) -} - -data class UpdatesNodeList( - override val nodes: List, - override val edges: List, - override val pageInfo: PageInfo, - override val totalCount: Int -) : NodeList() { - data class UpdatesEdge( - override val cursor: Cursor, - override val node: UpdatesType - ) : Edge() - - companion object { - fun List.toNodeList(): UpdatesNodeList { - return UpdatesNodeList( - nodes = this, - edges = getEdges(), - pageInfo = PageInfo( - hasNextPage = false, - hasPreviousPage = false, - startCursor = Cursor(0.toString()), - endCursor = Cursor(lastIndex.toString()) - ), - totalCount = size - ) - } - - private fun List.getEdges(): List { - if (isEmpty()) return emptyList() - return listOf( - UpdatesEdge( - cursor = Cursor("0"), - node = first() - ), - UpdatesEdge( - cursor = Cursor(lastIndex.toString()), - node = last() - ) - ) - } - } -}