Fix queries and mappers to work with updated views

This commit is contained in:
NGB-Was-Taken
2025-11-15 15:17:00 +05:45
parent 2b8641c1dd
commit bdbaecd975
4 changed files with 24 additions and 12 deletions
@@ -62,7 +62,7 @@ class LibraryQuery(
coalesce(C.fetchedAt, 0) AS chapterFetchedAt,
coalesce(C.lastRead, 0) AS lastRead,
coalesce(C.bookmarkCount, 0) AS bookmarkCount,
coalesce(MC.category_id, 0) AS category
coalesce(MC.categories, '0') AS categories
FROM mangas M
LEFT JOIN(
SELECT
@@ -83,7 +83,11 @@ class LibraryQuery(
GROUP BY chapters.manga_id
) AS C
ON M._id = C.manga_id
LEFT JOIN mangas_categories AS MC
LEFT JOIN (
SELECT manga_id, group_concat(category_id) AS categories
FROM mangas_categories
GROUP BY manga_id
) AS MC
ON MC.manga_id = M._id
WHERE $condition AND M.source <> $MERGED_SOURCE_ID
UNION
@@ -95,7 +99,7 @@ class LibraryQuery(
coalesce(C.fetchedAt, 0) AS chapterFetchedAt,
coalesce(C.lastRead, 0) AS lastRead,
coalesce(C.bookmarkCount, 0) AS bookmarkCount,
coalesce(MC.category_id, 0) AS category
coalesce(MC.categories, '0') AS categories
FROM mangas M
LEFT JOIN (
SELECT merged.manga_id,merged.merge_id
@@ -124,7 +128,11 @@ class LibraryQuery(
GROUP BY ME.merge_id
) AS C
ON ME.merge_id = C.merge_id
LEFT JOIN mangas_categories AS MC
LEFT JOIN (
SELECT manga_id, group_concat(category_id) AS categories
FROM mangas_categories
GROUP BY manga_id
) AS MC
ON MC.manga_id = M._id
WHERE $condition AND M.source = $MERGED_SOURCE_ID;
""".trimIndent(),
@@ -14,15 +14,16 @@ private val mapper = { cursor: SqlCursor ->
cursor.getLong(2)!!,
cursor.getString(3)!!,
cursor.getString(4),
cursor.getLong(5)!! == 1L,
cursor.getString(5)!!,
cursor.getLong(6)!! == 1L,
cursor.getLong(7)!!,
cursor.getLong(7)!! == 1L,
cursor.getLong(8)!!,
cursor.getLong(9)!! == 1L,
cursor.getString(10),
cursor.getLong(11)!!,
cursor.getLong(9)!!,
cursor.getLong(10)!! == 1L,
cursor.getString(11),
cursor.getLong(12)!!,
cursor.getLong(13)!!,
cursor.getLong(14)!!,
)
}
@@ -37,6 +38,7 @@ class UpdatesQuery(val driver: SqlDriver, val after: Long, val limit: Long) : Ex
chapters._id AS chapterId,
chapters.name AS chapterName,
chapters.scanlator,
chapters.url AS chapterUrl,
chapters.read,
chapters.bookmark,
chapters.last_page_read,
@@ -58,6 +60,7 @@ class UpdatesQuery(val driver: SqlDriver, val after: Long, val limit: Long) : Ex
chapters._id AS chapterId,
chapters.name AS chapterName,
chapters.scanlator,
chapters.url AS chapterUrl,
chapters.read,
chapters.bookmark,
chapters.last_page_read,
@@ -103,7 +103,7 @@ object MangaMapper {
chapterFetchedAt: Long,
lastRead: Long,
bookmarkCount: Double,
category: Long,
categories: String,
): LibraryManga = LibraryManga(
manga = mapManga(
id,
@@ -135,7 +135,7 @@ object MangaMapper {
isSyncing,
notes,
),
category = category,
categories = categories.split(",").map { it.toLong() },
totalChapters = totalCount,
readCount = readCount.toLong(),
bookmarkCount = bookmarkCount.toLong(),
@@ -237,7 +237,7 @@ object MangaMapper {
version = libraryView.version,
notes = libraryView.notes,
),
category = libraryView.category,
categories = libraryView.categories.split(",").map { it.toLong() },
totalChapters = libraryView.totalCount,
readCount = libraryView.readCount.toLong(),
bookmarkCount = libraryView.bookmarkCount.toLong(),
@@ -100,6 +100,7 @@ class UpdatesRepositoryImpl(
chapterId = updatesView.chapterId,
chapterName = updatesView.chapterName,
scanlator = updatesView.scanlator,
chapterUrl = updatesView.chapterUrl,
read = updatesView.read,
bookmark = updatesView.bookmark,
lastPageRead = updatesView.last_page_read,