Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move trigger for track progress update to client #918

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import suwayomi.tachidesk.graphql.types.ChapterMetaType
import suwayomi.tachidesk.graphql.types.ChapterType
import suwayomi.tachidesk.manga.impl.Chapter
import suwayomi.tachidesk.manga.impl.chapter.getChapterDownloadReadyById
import suwayomi.tachidesk.manga.impl.track.Track
import suwayomi.tachidesk.manga.model.table.ChapterMetaTable
import suwayomi.tachidesk.manga.model.table.ChapterTable
import suwayomi.tachidesk.server.JavalinSetup.future
Expand Down Expand Up @@ -70,13 +69,6 @@ class ChapterMutation {
update[lastReadAt] = now
}
}
if (patch.isRead == true) {
val mangaIds =
ChapterTable.slice(ChapterTable.manga).select { ChapterTable.id inList ids }
.map { it[ChapterTable.manga].value }
.toSet()
Track.asyncTrackChapter(mangaIds)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,33 @@ class TrackMutation {
}
}

data class TrackProgressInput(
val clientMutationId: String? = null,
val mangaId: Int,
)

data class TrackProgressPayload(
val clientMutationId: String?,
val trackRecords: List<TrackRecordType>,
)

fun trackProgress(input: TrackProgressInput): CompletableFuture<TrackProgressPayload> {
val (clientMutationId, mangaId) = input

return future {
Track.trackChapter(mangaId)
val trackRecords =
transaction {
TrackRecordTable.select { TrackRecordTable.mangaId eq mangaId }
.toList()
}
TrackProgressPayload(
clientMutationId,
trackRecords.map { TrackRecordType(it) },
)
}
}

data class UpdateTrackInput(
val clientMutationId: String? = null,
val recordId: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ object Track {
}
}

private suspend fun trackChapter(mangaId: Int) {
suspend fun trackChapter(mangaId: Int) {
val chapter = queryMaxReadChapter(mangaId)
val chapterNumber = chapter?.get(ChapterTable.chapter_number)
logger.debug {
Expand Down
Loading