mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
chore(recents): Use sql query to filter scanlators
This commit is contained in:
parent
7341e10822
commit
7926590c22
3 changed files with 36 additions and 7 deletions
|
@ -8,17 +8,27 @@ import eu.kanade.tachiyomi.data.database.tables.HistoryTable as History
|
||||||
import eu.kanade.tachiyomi.data.database.tables.MangaCategoryTable as MangaCategory
|
import eu.kanade.tachiyomi.data.database.tables.MangaCategoryTable as MangaCategory
|
||||||
import eu.kanade.tachiyomi.data.database.tables.MangaTable as Manga
|
import eu.kanade.tachiyomi.data.database.tables.MangaTable as Manga
|
||||||
|
|
||||||
|
// TODO: Migrate to SQLDelight
|
||||||
/**
|
/**
|
||||||
* Query to get the recent chapters of manga from the library up to a date.
|
* Query to get the recent chapters of manga from the library up to a date.
|
||||||
*/
|
*/
|
||||||
fun getRecentsQuery(search: String, offset: Int, isResuming: Boolean) =
|
fun getRecentsQuery(search: String, offset: Int, isResuming: Boolean) =
|
||||||
"""
|
"""
|
||||||
SELECT ${Manga.TABLE}.${Manga.COL_URL} as mangaUrl, * FROM ${Manga.TABLE} JOIN ${Chapter.TABLE}
|
SELECT
|
||||||
ON ${Manga.TABLE}.${Manga.COL_ID} = ${Chapter.TABLE}.${Chapter.COL_MANGA_ID}
|
M.url AS mangaUrl,
|
||||||
WHERE ${Manga.COL_FAVORITE} = 1
|
M.*,
|
||||||
AND ${Chapter.COL_DATE_FETCH} > ${Manga.COL_DATE_ADDED}
|
C.*
|
||||||
AND lower(${Manga.COL_TITLE}) LIKE '%$search%'
|
FROM mangas AS M
|
||||||
ORDER BY ${Chapter.COL_DATE_FETCH} DESC
|
JOIN chapters AS C
|
||||||
|
ON M._id = C.manga_id
|
||||||
|
LEFT JOIN scanlators_view AS S
|
||||||
|
ON C.manga_id = S.manga_id
|
||||||
|
AND ifnull(C.scanlator, 'N/A') = ifnull(S.name, '/<INVALID>/')
|
||||||
|
WHERE M.favorite = 1
|
||||||
|
AND C.date_fetch > M.date_added
|
||||||
|
AND lower(M.title) LIKE '%$search%'
|
||||||
|
AND S.name IS NULL
|
||||||
|
ORDER BY C.date_fetch DESC
|
||||||
${limitAndOffset(true, isResuming, offset)}
|
${limitAndOffset(true, isResuming, offset)}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,6 @@ class RecentsPresenter(
|
||||||
.mapNotNull { (key, mcs) ->
|
.mapNotNull { (key, mcs) ->
|
||||||
val manga = mcs.first().manga
|
val manga = mcs.first().manga
|
||||||
val chapters = mcs.map { ChapterHistory(it.chapter) }
|
val chapters = mcs.map { ChapterHistory(it.chapter) }
|
||||||
.filterChaptersByScanlators(manga)
|
|
||||||
extraCount += mcs.size - chapters.size
|
extraCount += mcs.size - chapters.size
|
||||||
if (chapters.isEmpty()) return@mapNotNull null
|
if (chapters.isEmpty()) return@mapNotNull null
|
||||||
val existingItem = recentItems.takeLast(ENDLESS_LIMIT).find {
|
val existingItem = recentItems.takeLast(ENDLESS_LIMIT).find {
|
||||||
|
|
|
@ -32,6 +32,26 @@ AND (
|
||||||
:apply_filter = 0 OR S.name IS NULL
|
:apply_filter = 0 OR S.name IS NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
getRecents:
|
||||||
|
SELECT
|
||||||
|
M.url AS mangaUrl,
|
||||||
|
M.*,
|
||||||
|
C.*
|
||||||
|
FROM mangas AS M
|
||||||
|
JOIN chapters AS C
|
||||||
|
ON M._id = C.manga_id
|
||||||
|
LEFT JOIN scanlators_view AS S
|
||||||
|
ON C.manga_id = S.manga_id
|
||||||
|
AND ifnull(C.scanlator, 'N/A') = ifnull(S.name, '/<INVALID>/') -- I assume if it's N/A it shouldn't be filtered
|
||||||
|
WHERE M.favorite = 1
|
||||||
|
AND C.date_fetch > M.date_added
|
||||||
|
AND lower(M.title) LIKE :search
|
||||||
|
AND (
|
||||||
|
:apply_filter = 0 OR S.name IS NULL
|
||||||
|
)
|
||||||
|
ORDER BY C.date_fetch DESC
|
||||||
|
LIMIT :limit OFFSET :offset;
|
||||||
|
|
||||||
getScanlatorsByMangaId:
|
getScanlatorsByMangaId:
|
||||||
SELECT scanlator
|
SELECT scanlator
|
||||||
FROM chapters
|
FROM chapters
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue