docs(sql): Documentate this insanity of a query [skip ci]

This commit is contained in:
Ahmad Ansori Palembani 2024-12-10 09:34:36 +07:00
parent 160a7109da
commit 1cb635999e
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -110,14 +110,14 @@ ORDER BY max_last_read.history_last_read DESC
LIMIT :limit OFFSET :offset; LIMIT :limit OFFSET :offset;
getRecentsAll: getRecentsAll:
SELECT SELECT -- Recently read manga
M.*, M.*,
C.*, C.*,
history.history_id AS history_id, history.history_id AS history_id,
history.history_chapter_id AS history_chapter_id, history.history_chapter_id AS history_chapter_id,
history.history_last_read AS history_last_read, history.history_last_read AS history_last_read,
history.history_time_read AS history_time_read history.history_time_read AS history_time_read
FROM ( FROM ( -- Check if there's any unread chapters and whether to include read chapters
SELECT M2.* SELECT M2.*
FROM mangas AS M2 FROM mangas AS M2
LEFT JOIN ( LEFT JOIN (
@ -145,7 +145,7 @@ JOIN (
FROM chapters AS C2 JOIN history AS H2 FROM chapters AS C2 JOIN history AS H2
ON C2._id = H2.history_chapter_id ON C2._id = H2.history_chapter_id
GROUP BY C2.manga_id GROUP BY C2.manga_id
) AS max_last_read ) AS max_last_read -- Most recent chapters
ON C.manga_id = max_last_read.manga_id ON C.manga_id = max_last_read.manga_id
AND max_last_read.history_chapter_id = history.history_chapter_id AND max_last_read.history_chapter_id = history.history_chapter_id
AND max_last_read.history_last_read > 0 AND max_last_read.history_last_read > 0
@ -157,7 +157,7 @@ AND (
:apply_filter = 0 OR S.name IS NULL :apply_filter = 0 OR S.name IS NULL
) )
UNION -- Newly added chapter UNION -- Newly fetched chapter
SELECT SELECT
M.*, M.*,