Change Track.bind to use trackerId + remoteId (#842)
This commit is contained in:
@@ -8,7 +8,6 @@ import suwayomi.tachidesk.graphql.types.TrackerType
|
||||
import suwayomi.tachidesk.manga.impl.track.Track
|
||||
import suwayomi.tachidesk.manga.impl.track.tracker.TrackerManager
|
||||
import suwayomi.tachidesk.manga.model.table.TrackRecordTable
|
||||
import suwayomi.tachidesk.manga.model.table.TrackSearchTable
|
||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
@@ -103,7 +102,8 @@ class TrackMutation {
|
||||
data class BindTrackInput(
|
||||
val clientMutationId: String? = null,
|
||||
val mangaId: Int,
|
||||
val trackSearchId: Int,
|
||||
val trackerId: Int,
|
||||
val remoteId: Long,
|
||||
)
|
||||
|
||||
data class BindTrackPayload(
|
||||
@@ -112,18 +112,16 @@ class TrackMutation {
|
||||
)
|
||||
|
||||
fun bindTrack(input: BindTrackInput): CompletableFuture<BindTrackPayload> {
|
||||
val (clientMutationId, mangaId, trackSearchId) = input
|
||||
val (clientMutationId, mangaId, trackerId, remoteId) = input
|
||||
|
||||
return future {
|
||||
Track.bind(
|
||||
mangaId,
|
||||
trackSearchId,
|
||||
trackerId,
|
||||
remoteId,
|
||||
)
|
||||
val trackRecord =
|
||||
transaction {
|
||||
val trackerId =
|
||||
TrackSearchTable.select { TrackSearchTable.id eq trackSearchId }
|
||||
.first()[TrackSearchTable.trackerId]
|
||||
TrackRecordTable.select {
|
||||
TrackRecordTable.mangaId eq mangaId and (TrackRecordTable.trackerId eq trackerId)
|
||||
}.first()
|
||||
|
||||
@@ -105,15 +105,16 @@ object TrackController {
|
||||
val bind =
|
||||
handler(
|
||||
queryParam<Int>("mangaId"),
|
||||
queryParam<Int>("trackSearchId"),
|
||||
queryParam<Int>("trackerId"),
|
||||
queryParam<String>("remoteId"),
|
||||
documentWith = {
|
||||
withOperation {
|
||||
summary("Track Record Bind")
|
||||
description("Bind a Track Record to a Manga")
|
||||
}
|
||||
},
|
||||
behaviorOf = { ctx, mangaId, trackSearchId ->
|
||||
ctx.future(future { Track.bind(mangaId, trackSearchId) })
|
||||
behaviorOf = { ctx, mangaId, trackerId, remoteId ->
|
||||
ctx.future(future { Track.bind(mangaId, trackerId, remoteId.toLong()) })
|
||||
},
|
||||
withResults = {
|
||||
httpCode(HttpCode.OK)
|
||||
|
||||
@@ -50,7 +50,6 @@ import suwayomi.tachidesk.server.serverConfig
|
||||
import java.time.Instant
|
||||
import java.util.TreeSet
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.collections.listOf
|
||||
import kotlin.math.max
|
||||
|
||||
object Chapter {
|
||||
@@ -140,6 +139,10 @@ object Chapter {
|
||||
val numberOfCurrentChapters = getCountOfMangaChapters(mangaId)
|
||||
val chapterList = source.getChapterList(sManga)
|
||||
|
||||
if (chapterList.isEmpty()) {
|
||||
throw Exception("No chapters found")
|
||||
}
|
||||
|
||||
// Recognize number for new chapters.
|
||||
chapterList.forEach { chapter ->
|
||||
(source as? HttpSource)?.prepareNewChapter(chapter, sManga)
|
||||
@@ -346,7 +349,7 @@ object Chapter {
|
||||
}
|
||||
|
||||
if (mangaCategories.isNotEmpty()) {
|
||||
var downloadCategoriesMap = Category.getCategoryList().groupBy { it.includeInDownload }
|
||||
val downloadCategoriesMap = Category.getCategoryList().groupBy { it.includeInDownload }
|
||||
val unsetCategories = downloadCategoriesMap[IncludeOrExclude.UNSET].orEmpty()
|
||||
// We only download if it's in the include list, and not in the exclude list.
|
||||
// Use the unset categories as the included categories if the included categories is
|
||||
@@ -354,12 +357,12 @@ object Chapter {
|
||||
val includedCategories = downloadCategoriesMap[IncludeOrExclude.INCLUDE].orEmpty().ifEmpty { unsetCategories }
|
||||
val excludedCategories = downloadCategoriesMap[IncludeOrExclude.EXCLUDE].orEmpty()
|
||||
// Only download manga that aren't in any excluded categories
|
||||
val mangaExcludeCategories = mangaCategories.intersect(excludedCategories)
|
||||
val mangaExcludeCategories = mangaCategories.intersect(excludedCategories.toSet())
|
||||
if (mangaExcludeCategories.isNotEmpty()) {
|
||||
log.debug { "download excluded by categories: '${mangaExcludeCategories.joinToString("', '") { it.name }}'" }
|
||||
return
|
||||
}
|
||||
val mangaDownloadCategories = mangaCategories.intersect(includedCategories)
|
||||
val mangaDownloadCategories = mangaCategories.intersect(includedCategories.toSet())
|
||||
if (mangaDownloadCategories.isNotEmpty()) {
|
||||
log.debug { "download inluded by categories: '${mangaDownloadCategories.joinToString("', '") { it.name }}'" }
|
||||
} else {
|
||||
|
||||
@@ -137,14 +137,17 @@ object Track {
|
||||
|
||||
suspend fun bind(
|
||||
mangaId: Int,
|
||||
trackSearchId: Int,
|
||||
trackerId: Int,
|
||||
remoteId: Long,
|
||||
) {
|
||||
val track =
|
||||
transaction {
|
||||
TrackSearchTable.select { TrackSearchTable.id eq trackSearchId }.first()
|
||||
.toTrack(mangaId)
|
||||
TrackSearchTable.select {
|
||||
TrackSearchTable.trackerId eq trackerId and
|
||||
(TrackSearchTable.remoteId eq remoteId)
|
||||
}.first().toTrack(mangaId)
|
||||
}
|
||||
val tracker = TrackerManager.getTracker(track.sync_id)!!
|
||||
val tracker = TrackerManager.getTracker(trackerId)!!
|
||||
|
||||
val chapter = queryMaxReadChapter(mangaId)
|
||||
val hasReadChapters = chapter != null
|
||||
|
||||
Reference in New Issue
Block a user