This commit is contained in:
Jays2Kings 2021-04-20 23:01:52 -04:00
parent b87e768e0a
commit d5c7b09908

View File

@ -123,6 +123,7 @@ fun getRecentMangasLimitQuery(
GROUP BY ${Chapter.TABLE}.${Chapter.COL_MANGA_ID}) AS max_last_read GROUP BY ${Chapter.TABLE}.${Chapter.COL_MANGA_ID}) AS max_last_read
ON ${Chapter.TABLE}.${Chapter.COL_MANGA_ID} = max_last_read.${Chapter.COL_MANGA_ID} ON ${Chapter.TABLE}.${Chapter.COL_MANGA_ID} = max_last_read.${Chapter.COL_MANGA_ID}
AND max_last_read.${History.COL_CHAPTER_ID} = ${History.TABLE}.${History.COL_CHAPTER_ID} AND max_last_read.${History.COL_CHAPTER_ID} = ${History.TABLE}.${History.COL_CHAPTER_ID}
AND max_last_read.${History.COL_LAST_READ} > 0
AND lower(${Manga.TABLE}.${Manga.COL_TITLE}) LIKE '%$search%' AND lower(${Manga.TABLE}.${Manga.COL_TITLE}) LIKE '%$search%'
ORDER BY max_last_read.${History.COL_LAST_READ} DESC ORDER BY max_last_read.${History.COL_LAST_READ} DESC
${limitAndOffset(endless, isResuming, offset)} ${limitAndOffset(endless, isResuming, offset)}
@ -165,13 +166,14 @@ fun getAllRecentsType(
JOIN history JOIN history
ON chapters._id = history.history_chapter_id ON chapters._id = history.history_chapter_id
JOIN ( JOIN (
SELECT chapters.manga_id,chapters._id as history_chapter_id, MAX(history.history_last_read) as history_last_read SELECT ${Chapter.TABLE}.${Chapter.COL_MANGA_ID},${Chapter.TABLE}.${Chapter.COL_ID} as ${History.COL_CHAPTER_ID}, MAX(${History.TABLE}.${History.COL_LAST_READ}) as ${History.COL_LAST_READ}
FROM chapters JOIN history FROM ${Chapter.TABLE} JOIN ${History.TABLE}
ON chapters._id = history.history_chapter_id ON ${Chapter.TABLE}.${Chapter.COL_ID} = ${History.TABLE}.${History.COL_CHAPTER_ID}
GROUP BY chapters.manga_id) AS max_last_read GROUP BY ${Chapter.TABLE}.${Chapter.COL_MANGA_ID}) AS max_last_read
ON chapters.manga_id = max_last_read.manga_id ON ${Chapter.TABLE}.${Chapter.COL_MANGA_ID} = max_last_read.${Chapter.COL_MANGA_ID}
AND max_last_read.history_chapter_id = history.history_chapter_id AND max_last_read.${History.COL_CHAPTER_ID} = ${History.TABLE}.${History.COL_CHAPTER_ID}
AND lower(mangas.title) LIKE '%$search%') AND max_last_read.${History.COL_LAST_READ} > 0
AND lower(${Manga.COL_TITLE}) LIKE '%$search%')
UNION UNION
SELECT * FROM SELECT * FROM
(SELECT ${Manga.TABLE}.${Manga.COL_URL} as mangaUrl, ${Manga.TABLE}.*, ${Chapter.TABLE}.*, (SELECT ${Manga.TABLE}.${Manga.COL_URL} as mangaUrl, ${Manga.TABLE}.*, ${Chapter.TABLE}.*,
@ -210,7 +212,10 @@ fun getAllRecentsType(
Null as pages_left, Null as pages_left,
Null as chapter_number, Null as chapter_number,
Null as source_order, Null as source_order,
Null as history_id, Null as history_chapter_id, mangas.date_added as history_last_read, Null as history_time_read Null as history_id,
Null as history_chapter_id,
${Manga.TABLE}.${Manga.COL_DATE_ADDED} as history_last_read,
Null as history_time_read
FROM mangas FROM mangas
WHERE ${Manga.COL_FAVORITE} = 1 WHERE ${Manga.COL_FAVORITE} = 1
AND lower(${Manga.COL_TITLE}) LIKE '%$search%') AND lower(${Manga.COL_TITLE}) LIKE '%$search%')