mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-02 10:24:35 -05:00
Add updates
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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.SqlExpressionBuilder.eq
|
||||||
|
import org.jetbrains.exposed.sql.SqlExpressionBuilder.greater
|
||||||
|
import org.jetbrains.exposed.sql.and
|
||||||
|
import org.jetbrains.exposed.sql.select
|
||||||
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
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
|
||||||
|
*
|
||||||
|
* TODO Mutations
|
||||||
|
* - Update the library
|
||||||
|
* - Update a category
|
||||||
|
* - Reset updater
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class UpdatesQuery {
|
||||||
|
data class UpdatesQueryInput(
|
||||||
|
val page: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
fun updates(input: UpdatesQueryInput): List<UpdatesType> {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ import suwayomi.tachidesk.graphql.queries.ExtensionQuery
|
|||||||
import suwayomi.tachidesk.graphql.queries.MangaQuery
|
import suwayomi.tachidesk.graphql.queries.MangaQuery
|
||||||
import suwayomi.tachidesk.graphql.queries.MetaQuery
|
import suwayomi.tachidesk.graphql.queries.MetaQuery
|
||||||
import suwayomi.tachidesk.graphql.queries.SourceQuery
|
import suwayomi.tachidesk.graphql.queries.SourceQuery
|
||||||
|
import suwayomi.tachidesk.graphql.queries.UpdatesQuery
|
||||||
import suwayomi.tachidesk.graphql.subscriptions.DownloadSubscription
|
import suwayomi.tachidesk.graphql.subscriptions.DownloadSubscription
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
import kotlin.reflect.KType
|
import kotlin.reflect.KType
|
||||||
@@ -43,7 +44,8 @@ val schema = toSchema(
|
|||||||
TopLevelObject(CategoryQuery()),
|
TopLevelObject(CategoryQuery()),
|
||||||
TopLevelObject(SourceQuery()),
|
TopLevelObject(SourceQuery()),
|
||||||
TopLevelObject(ExtensionQuery()),
|
TopLevelObject(ExtensionQuery()),
|
||||||
TopLevelObject(MetaQuery())
|
TopLevelObject(MetaQuery()),
|
||||||
|
TopLevelObject(UpdatesQuery())
|
||||||
),
|
),
|
||||||
mutations = listOf(
|
mutations = listOf(
|
||||||
TopLevelObject(ChapterMutation())
|
TopLevelObject(ChapterMutation())
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
class UpdatesType(
|
||||||
|
val manga: MangaType,
|
||||||
|
val chapter: ChapterType
|
||||||
|
) {
|
||||||
|
constructor(row: ResultRow) : this(
|
||||||
|
manga = MangaType(row),
|
||||||
|
chapter = ChapterType(row)
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user