mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-10 14:24:34 -05:00
The update subscription emitted the full update status, which, depending on how big the status was, took forever because the graphql subscription does not support data loader batching, causing it to run into the n+1 problem
26 lines
1.0 KiB
Kotlin
26 lines
1.0 KiB
Kotlin
package suwayomi.tachidesk.graphql.queries
|
|
|
|
import com.expediagroup.graphql.generator.annotations.GraphQLDeprecated
|
|
import kotlinx.coroutines.flow.first
|
|
import suwayomi.tachidesk.graphql.types.LibraryUpdateStatus
|
|
import suwayomi.tachidesk.graphql.types.UpdateStatus
|
|
import suwayomi.tachidesk.manga.impl.update.IUpdater
|
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
|
import uy.kohesive.injekt.injectLazy
|
|
import java.util.concurrent.CompletableFuture
|
|
|
|
class UpdateQuery {
|
|
private val updater: IUpdater by injectLazy()
|
|
|
|
@GraphQLDeprecated("Replaced with libraryUpdateStatus", ReplaceWith("libraryUpdateStatus"))
|
|
fun updateStatus(): CompletableFuture<UpdateStatus> = future { UpdateStatus(updater.status.first()) }
|
|
|
|
fun libraryUpdateStatus(): CompletableFuture<LibraryUpdateStatus> = future { LibraryUpdateStatus(updater.getStatus()) }
|
|
|
|
data class LastUpdateTimestampPayload(
|
|
val timestamp: Long,
|
|
)
|
|
|
|
fun lastUpdateTimestamp(): LastUpdateTimestampPayload = LastUpdateTimestampPayload(updater.getLastUpdateTimestamp())
|
|
}
|