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

Fix Graphql Tracking #840

Merged
merged 1 commit into from
Jan 22, 2024
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,6 +10,7 @@ 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 @@ -69,6 +70,13 @@ 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 @@ -439,7 +439,7 @@ object Chapter {
}

if (isRead == true || markPrevRead == true) {
Track.asyncTrackChapter(mangaId)
Track.asyncTrackChapter(setOf(mangaId))
}
}

Expand Down Expand Up @@ -527,9 +527,9 @@ object Chapter {
transaction {
ChapterTable.select { condition }
.map { it[ChapterTable.manga].value }
.distinct()
.toSet()
}
mangaIds.forEach { Track.asyncTrackChapter(it) }
Track.asyncTrackChapter(mangaIds)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,14 @@ object Track {
upsertTrackRecord(track)
}

fun asyncTrackChapter(mangaId: Int) {
fun asyncTrackChapter(mangaIds: Set<Int>) {
if (!TrackerManager.hasLoggedTracker()) {
return
}
scope.launch {
trackChapter(mangaId)
mangaIds.forEach {
trackChapter(it)
}
}
}

Expand Down Expand Up @@ -266,10 +271,6 @@ object Track {
mangaId: Int,
chapterNumber: Double,
) {
if (!TrackerManager.hasLoggedTracker()) {
return
}

val records =
transaction {
TrackRecordTable.select { TrackRecordTable.mangaId eq mangaId }
Expand Down