2022-04-23 05:29:24 +08:00
|
|
|
import java.lang.String;
|
|
|
|
import kotlin.collections.List;
|
|
|
|
|
|
|
|
CREATE TABLE mangas(
|
|
|
|
_id INTEGER NOT NULL PRIMARY KEY,
|
|
|
|
source INTEGER NOT NULL,
|
|
|
|
url TEXT NOT NULL,
|
|
|
|
artist TEXT,
|
|
|
|
author TEXT,
|
|
|
|
description TEXT,
|
|
|
|
genre TEXT AS List<String>,
|
|
|
|
title TEXT NOT NULL,
|
|
|
|
status INTEGER NOT NULL,
|
|
|
|
thumbnail_url TEXT,
|
|
|
|
favorite INTEGER AS Boolean NOT NULL,
|
|
|
|
last_update INTEGER AS Long,
|
|
|
|
next_update INTEGER AS Long,
|
|
|
|
initialized INTEGER AS Boolean NOT NULL,
|
|
|
|
viewer INTEGER NOT NULL,
|
|
|
|
chapter_flags INTEGER NOT NULL,
|
|
|
|
cover_last_modified INTEGER AS Long NOT NULL,
|
|
|
|
date_added INTEGER AS Long NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE INDEX library_favorite_index ON mangas(favorite) WHERE favorite = 1;
|
|
|
|
CREATE INDEX mangas_url_index ON mangas(url);
|
|
|
|
|
|
|
|
getMangaById:
|
|
|
|
SELECT *
|
|
|
|
FROM mangas
|
2022-04-27 20:36:16 +08:00
|
|
|
WHERE _id = :id;
|
|
|
|
|
|
|
|
getSourceIdWithFavoriteCount:
|
|
|
|
SELECT
|
|
|
|
source,
|
|
|
|
count(*)
|
|
|
|
FROM mangas
|
|
|
|
WHERE favorite = 1
|
2022-04-30 21:37:10 +08:00
|
|
|
GROUP BY source;
|
|
|
|
|
|
|
|
getFavoriteBySourceId:
|
|
|
|
SELECT *
|
|
|
|
FROM mangas
|
|
|
|
WHERE favorite = 1
|
2022-05-12 21:00:57 +08:00
|
|
|
AND source = :sourceId;
|
|
|
|
|
|
|
|
resetViewerFlags:
|
|
|
|
UPDATE mangas
|
2022-06-11 09:33:56 +08:00
|
|
|
SET viewer = 0;
|
|
|
|
|
|
|
|
getSourceIdsWithNonLibraryManga:
|
|
|
|
SELECT source, COUNT(*) AS manga_count
|
|
|
|
FROM mangas
|
|
|
|
WHERE favorite = 0
|
|
|
|
GROUP BY source;
|
|
|
|
|
|
|
|
deleteMangasNotInLibraryBySourceIds:
|
|
|
|
DELETE FROM mangas
|
2022-06-11 23:38:39 +08:00
|
|
|
WHERE favorite = 0 AND source IN :sourceIds;
|
|
|
|
|
|
|
|
updateLastUpdate:
|
|
|
|
UPDATE mangas
|
|
|
|
SET last_update = :lastUpdate
|
|
|
|
WHERE _id = :mangaId;
|