mirror of
https://github.com/null2264/yokai.git
synced 2025-06-20 18:24:42 +00:00
chore: Preparing to migrate History to SQLDelight
This commit is contained in:
parent
10b9fa53a6
commit
61e43e047f
5 changed files with 82 additions and 67 deletions
|
@ -77,60 +77,6 @@ AND (
|
|||
ORDER BY C.date_fetch DESC
|
||||
LIMIT :limit OFFSET :offset;
|
||||
|
||||
getRecentsUngrouped:
|
||||
SELECT
|
||||
M.*,
|
||||
C.*,
|
||||
H.*
|
||||
FROM mangas AS M
|
||||
JOIN chapters AS C
|
||||
ON M._id = C.manga_id
|
||||
JOIN history AS H
|
||||
ON C._id = H.history_chapter_id
|
||||
AND H.history_last_read > 0
|
||||
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 lower(M.title) LIKE '%' || :search || '%'
|
||||
AND (
|
||||
:apply_filter = 0 OR S.name IS NULL
|
||||
)
|
||||
ORDER BY H.history_last_read DESC
|
||||
LIMIT :limit OFFSET :offset;
|
||||
|
||||
getRecentsBySeries:
|
||||
SELECT
|
||||
M.url AS mangaUrl,
|
||||
M.*,
|
||||
C.*,
|
||||
H.*
|
||||
FROM mangas AS M
|
||||
JOIN chapters AS C
|
||||
ON M._id = C.manga_id
|
||||
JOIN history AS H
|
||||
ON C._id = H.history_chapter_id
|
||||
JOIN (
|
||||
SELECT
|
||||
C2.manga_id AS manga_id,
|
||||
C2._id AS history_chapter_id,
|
||||
MAX(H2.history_last_read) AS history_last_read
|
||||
FROM chapters AS C2 JOIN history AS H2
|
||||
ON C2._id = H2.history_chapter_id
|
||||
GROUP BY C2.manga_id
|
||||
) AS max_last_read
|
||||
ON C.manga_id = max_last_read.manga_id
|
||||
AND max_last_read.history_chapter_id = H.history_chapter_id
|
||||
AND max_last_read.history_last_read > 0
|
||||
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 lower(M.title) LIKE '%' || :search || '%'
|
||||
AND (
|
||||
:apply_filter = 0 OR S.name IS NULL
|
||||
)
|
||||
ORDER BY max_last_read.history_last_read DESC
|
||||
LIMIT :limit OFFSET :offset;
|
||||
|
||||
getScanlatorsByMangaId:
|
||||
SELECT scanlator
|
||||
FROM chapters
|
||||
|
|
|
@ -8,3 +8,57 @@ CREATE TABLE history(
|
|||
);
|
||||
|
||||
CREATE INDEX history_history_chapter_id_index ON history(history_chapter_id);
|
||||
|
||||
getRecentsUngrouped:
|
||||
SELECT
|
||||
M.*,
|
||||
C.*,
|
||||
H.*
|
||||
FROM mangas AS M
|
||||
JOIN chapters AS C
|
||||
ON M._id = C.manga_id
|
||||
JOIN history AS H
|
||||
ON C._id = H.history_chapter_id
|
||||
AND H.history_last_read > 0
|
||||
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 lower(M.title) LIKE '%' || :search || '%'
|
||||
AND (
|
||||
:apply_filter = 0 OR S.name IS NULL
|
||||
)
|
||||
ORDER BY H.history_last_read DESC
|
||||
LIMIT :limit OFFSET :offset;
|
||||
|
||||
getRecentsBySeries:
|
||||
SELECT
|
||||
M.url AS mangaUrl,
|
||||
M.*,
|
||||
C.*,
|
||||
H.*
|
||||
FROM mangas AS M
|
||||
JOIN chapters AS C
|
||||
ON M._id = C.manga_id
|
||||
JOIN history AS H
|
||||
ON C._id = H.history_chapter_id
|
||||
JOIN (
|
||||
SELECT
|
||||
C2.manga_id AS manga_id,
|
||||
C2._id AS history_chapter_id,
|
||||
MAX(H2.history_last_read) AS history_last_read
|
||||
FROM chapters AS C2 JOIN history AS H2
|
||||
ON C2._id = H2.history_chapter_id
|
||||
GROUP BY C2.manga_id
|
||||
) AS max_last_read
|
||||
ON C.manga_id = max_last_read.manga_id
|
||||
AND max_last_read.history_chapter_id = H.history_chapter_id
|
||||
AND max_last_read.history_last_read > 0
|
||||
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 lower(M.title) LIKE '%' || :search || '%'
|
||||
AND (
|
||||
:apply_filter = 0 OR S.name IS NULL
|
||||
)
|
||||
ORDER BY max_last_read.history_last_read DESC
|
||||
LIMIT :limit OFFSET :offset;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue