Skip to content

Commit

Permalink
Add function to get number of manga chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
schroda committed Jul 16, 2023
1 parent 7447d53 commit 80f431b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class ChapterMutation {
val (clientMutationId, mangaId) = input

return future {
val numberOfCurrentChapters = transaction { ChapterTable.select { ChapterTable.manga eq mangaId }.count().toInt() }
val numberOfCurrentChapters = Chapter.getCountOfMangaChapters(mangaId)
Chapter.fetchChapterList(mangaId)
numberOfCurrentChapters
}.thenApply { numberOfCurrentChapters ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ object Chapter {
}
}

fun getCountOfMangaChapters(mangaId: Int): Int {
return transaction { ChapterTable.select { ChapterTable.manga eq mangaId }.count().toInt() }
}

private suspend fun getSourceChapters(mangaId: Int): List<ChapterDataClass> {
val chapterList = fetchChapterList(mangaId)

Expand Down Expand Up @@ -113,8 +117,7 @@ object Chapter {
url = manga.url
}

val numberOfCurrentChapters =
transaction { ChapterTable.select { ChapterTable.manga eq mangaId }.count().toInt() }
val numberOfCurrentChapters = getCountOfMangaChapters(mangaId)
val chapterList = source.fetchChapterList(sManga).awaitSingle()

// Recognize number for new chapters.
Expand Down

0 comments on commit 80f431b

Please sign in to comment.