diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDtoDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDtoDao.kt index 5ffac33ae..86a236049 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDtoDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDtoDao.kt @@ -58,9 +58,15 @@ class ReadProgressDtoDao( .fetch() .toList() + val maxNumberSort = dsl.select(DSL.max(d.NUMBER_SORT)) + .from(b) + .leftJoin(d).on(b.ID.eq(d.BOOK_ID)) + .where(b.SERIES_ID.eq(seriesId)) + .fetchOne(DSL.max(d.NUMBER_SORT)) ?: 0F + val booksCount = getSeriesBooksCount(seriesId, userId) - return booksCountToDtoV2(booksCount, numberSortReadProgress.lastRead() ?: 0F) + return booksCountToDtoV2(booksCount, numberSortReadProgress.lastRead() ?: 0F, maxNumberSort) } private fun getSeriesBooksCount(seriesId: String, userId: String) = dsl @@ -122,13 +128,14 @@ class ReadProgressDtoDao( lastReadContinuousIndex = lastReadContinuousIndex, ) - private fun booksCountToDtoV2(booksCount: BooksCount, lastReadContinuousNumberSort: Float): TachiyomiReadProgressV2Dto = + private fun booksCountToDtoV2(booksCount: BooksCount, lastReadContinuousNumberSort: Float, maxNumberSort: Float): TachiyomiReadProgressV2Dto = TachiyomiReadProgressV2Dto( booksCount = booksCount.totalCount, booksUnreadCount = booksCount.unreadCount, booksInProgressCount = booksCount.inProgressCount, booksReadCount = booksCount.readCount, lastReadContinuousNumberSort = lastReadContinuousNumberSort, + maxNumberSort = maxNumberSort, ) private fun readProgressCondition(userId: String): Condition = r.USER_ID.eq(userId).or(r.USER_ID.isNull) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/dto/TachiyomiReadProgressV2Dto.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/dto/TachiyomiReadProgressV2Dto.kt index 1ede7781d..d5cc7e6b4 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/dto/TachiyomiReadProgressV2Dto.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/dto/TachiyomiReadProgressV2Dto.kt @@ -6,4 +6,5 @@ data class TachiyomiReadProgressV2Dto( val booksUnreadCount: Int, val booksInProgressCount: Int, val lastReadContinuousNumberSort: Float, + val maxNumberSort: Float, )