Skip to content

Commit

Permalink
Fix graphql tracking (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
Syer10 authored Jan 22, 2024
1 parent 0621138 commit b9053e3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
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

0 comments on commit b9053e3

Please sign in to comment.