mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-27 19:47:51 +02:00
Display total chapters on duplicates list items (#1963)
This commit is contained in:
@ -3,6 +3,7 @@ package tachiyomi.data.manga
|
||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
||||
import tachiyomi.domain.library.model.LibraryManga
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.model.MangaWithChapterCount
|
||||
|
||||
object MangaMapper {
|
||||
fun mapManga(
|
||||
@ -128,4 +129,62 @@ object MangaMapper {
|
||||
chapterFetchedAt = chapterFetchedAt,
|
||||
lastRead = lastRead,
|
||||
)
|
||||
|
||||
fun mapMangaWithChapterCount(
|
||||
id: Long,
|
||||
source: Long,
|
||||
url: String,
|
||||
artist: String?,
|
||||
author: String?,
|
||||
description: String?,
|
||||
genre: List<String>?,
|
||||
title: String,
|
||||
status: Long,
|
||||
thumbnailUrl: String?,
|
||||
favorite: Boolean,
|
||||
lastUpdate: Long?,
|
||||
nextUpdate: Long?,
|
||||
initialized: Boolean,
|
||||
viewerFlags: Long,
|
||||
chapterFlags: Long,
|
||||
coverLastModified: Long,
|
||||
dateAdded: Long,
|
||||
updateStrategy: UpdateStrategy,
|
||||
calculateInterval: Long,
|
||||
lastModifiedAt: Long,
|
||||
favoriteModifiedAt: Long?,
|
||||
version: Long,
|
||||
isSyncing: Long,
|
||||
notes: String,
|
||||
totalCount: Long,
|
||||
): MangaWithChapterCount = MangaWithChapterCount(
|
||||
manga = mapManga(
|
||||
id,
|
||||
source,
|
||||
url,
|
||||
artist,
|
||||
author,
|
||||
description,
|
||||
genre,
|
||||
title,
|
||||
status,
|
||||
thumbnailUrl,
|
||||
favorite,
|
||||
lastUpdate,
|
||||
nextUpdate,
|
||||
initialized,
|
||||
viewerFlags,
|
||||
chapterFlags,
|
||||
coverLastModified,
|
||||
dateAdded,
|
||||
updateStrategy,
|
||||
calculateInterval,
|
||||
lastModifiedAt,
|
||||
favoriteModifiedAt,
|
||||
version,
|
||||
isSyncing,
|
||||
notes,
|
||||
),
|
||||
chapterCount = totalCount,
|
||||
)
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import tachiyomi.data.UpdateStrategyColumnAdapter
|
||||
import tachiyomi.domain.library.model.LibraryManga
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.model.MangaUpdate
|
||||
import tachiyomi.domain.manga.model.MangaWithChapterCount
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
import java.time.LocalDate
|
||||
import java.time.ZoneId
|
||||
@ -65,9 +66,9 @@ class MangaRepositoryImpl(
|
||||
return handler.subscribeToList { mangasQueries.getFavoriteBySourceId(sourceId, MangaMapper::mapManga) }
|
||||
}
|
||||
|
||||
override suspend fun getDuplicateLibraryManga(id: Long, title: String): List<Manga> {
|
||||
override suspend fun getDuplicateLibraryManga(id: Long, title: String): List<MangaWithChapterCount> {
|
||||
return handler.awaitList {
|
||||
mangasQueries.getDuplicateLibraryManga(title, id, MangaMapper::mapManga)
|
||||
mangasQueries.getDuplicateLibraryManga(id, title, MangaMapper::mapMangaWithChapterCount)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,11 +116,33 @@ WHERE favorite = 1
|
||||
AND source = :sourceId;
|
||||
|
||||
getDuplicateLibraryManga:
|
||||
SELECT *
|
||||
FROM mangas
|
||||
WHERE favorite = 1
|
||||
AND lower(title) LIKE '%' || lower(:title) || '%'
|
||||
AND _id != :id;
|
||||
WITH
|
||||
duplicates AS (
|
||||
SELECT *
|
||||
FROM mangas
|
||||
WHERE favorite = 1
|
||||
AND _id != :id
|
||||
AND lower(title) LIKE '%' || lower(:title) || '%'
|
||||
),
|
||||
chapter_counts AS (
|
||||
SELECT
|
||||
M._id AS manga_id,
|
||||
count(*) AS chapter_count
|
||||
FROM duplicates M
|
||||
JOIN chapters C
|
||||
ON M._id = C.manga_id
|
||||
LEFT JOIN excluded_scanlators ES
|
||||
ON C.manga_id = ES.manga_id
|
||||
AND C.scanlator = ES.scanlator
|
||||
WHERE ES.scanlator IS NULL
|
||||
GROUP BY M._id
|
||||
)
|
||||
SELECT
|
||||
M.*,
|
||||
coalesce(CC.chapter_count, 0) AS chapter_count
|
||||
FROM duplicates M
|
||||
LEFT JOIN chapter_counts CC
|
||||
ON M._id = CC.manga_id;
|
||||
|
||||
getUpcomingManga:
|
||||
SELECT *
|
||||
|
Reference in New Issue
Block a user