Delete updates query since the chapters query can now mimic it
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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())
|
||||
|
||||
@@ -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<UpdatesType>,
|
||||
override val edges: List<UpdatesEdge>,
|
||||
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<UpdatesType>.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<UpdatesType>.getEdges(): List<UpdatesEdge> {
|
||||
if (isEmpty()) return emptyList()
|
||||
return listOf(
|
||||
UpdatesEdge(
|
||||
cursor = Cursor("0"),
|
||||
node = first()
|
||||
),
|
||||
UpdatesEdge(
|
||||
cursor = Cursor(lastIndex.toString()),
|
||||
node = last()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user