mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
chore: Prepare libraryView to replace libraryQuery
This commit is contained in:
parent
d0baff197c
commit
08225ee6a0
2 changed files with 33 additions and 0 deletions
23
app/src/main/sqldelight/tachiyomi/view/library_view.sq
Normal file
23
app/src/main/sqldelight/tachiyomi/view/library_view.sq
Normal file
|
@ -0,0 +1,23 @@
|
|||
CREATE VIEW library_view AS
|
||||
SELECT
|
||||
M.*,
|
||||
coalesce(MC.category_id, 0) AS category
|
||||
FROM (
|
||||
SELECT
|
||||
MS.*,
|
||||
coalesce(count(*) - sum(read), 0) AS unread,
|
||||
sum(read) AS has_read,
|
||||
sum(bookmark) AS bookmark_count
|
||||
FROM mangas AS MS
|
||||
LEFT JOIN chapters AS C
|
||||
ON C.manga_id = MS._id
|
||||
LEFT JOIN scanlators_view AS filtered_scanlators
|
||||
ON C.manga_id = filtered_scanlators._id
|
||||
AND ifnull(C.scanlator, 'N/A') = ifnull(filtered_scanlators.name, '/<INVALID>/') -- I assume if it's N/A it shouldn't be filtered
|
||||
WHERE MS.favorite = 1
|
||||
AND filtered_scanlators.name IS NULL
|
||||
GROUP BY MS._id
|
||||
ORDER BY MS.title
|
||||
) AS M
|
||||
LEFT JOIN mangas_categories AS MC
|
||||
ON MC.manga_id = M._id;
|
10
app/src/main/sqldelight/tachiyomi/view/scanlators_view.sq
Normal file
10
app/src/main/sqldelight/tachiyomi/view/scanlators_view.sq
Normal file
|
@ -0,0 +1,10 @@
|
|||
CREATE VIEW scanlators_view AS -- Probably should migrate these to a real table
|
||||
WITH RECURSIVE split(seq, _id, name, str) AS (
|
||||
SELECT 0, M._id, NULL, replace(ifnull(M.filtered_scanlators, ''), ' & ', ',')||',' FROM mangas AS M
|
||||
UNION ALL SELECT
|
||||
seq+1,
|
||||
_id,
|
||||
substr(str, 0, instr(str, ',')),
|
||||
substr(str, instr(str, ',')+1)
|
||||
FROM split WHERE str != ''
|
||||
) SELECT _id, name FROM split WHERE split.seq != 0 ORDER BY split.seq ASC;
|
Loading…
Add table
Add a link
Reference in a new issue