* Tweak library query Co-Authored-By: Quang Kieu <kieuq@wit.edu> * Update app/src/main/sqldelight/migrations/21.sqm * Update app/src/main/java/eu/kanade/domain/library/model/LibraryManga.kt * Update app/src/main/sqldelight/view/libraryView.sq * Update app/src/main/java/eu/kanade/data/manga/MangaMapper.kt * Update app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt * Update app/src/main/java/eu/kanade/data/manga/MangaMapper.kt * Bump version Co-authored-by: Quang Kieu <kieuq@wit.edu>
108 lines
3.0 KiB
Plaintext
108 lines
3.0 KiB
Plaintext
import eu.kanade.tachiyomi.source.model.UpdateStrategy;
|
|
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,
|
|
update_strategy INTEGER AS UpdateStrategy NOT NULL DEFAULT 0
|
|
);
|
|
|
|
CREATE INDEX library_favorite_index ON mangas(favorite) WHERE favorite = 1;
|
|
CREATE INDEX mangas_url_index ON mangas(url);
|
|
|
|
getMangaById:
|
|
SELECT *
|
|
FROM mangas
|
|
WHERE _id = :id;
|
|
|
|
getMangaByUrlAndSource:
|
|
SELECT *
|
|
FROM mangas
|
|
WHERE url = :url AND source = :source;
|
|
|
|
getFavorites:
|
|
SELECT *
|
|
FROM mangas
|
|
WHERE favorite = 1;
|
|
|
|
getSourceIdWithFavoriteCount:
|
|
SELECT
|
|
source,
|
|
count(*)
|
|
FROM mangas
|
|
WHERE favorite = 1
|
|
GROUP BY source;
|
|
|
|
getFavoriteBySourceId:
|
|
SELECT *
|
|
FROM mangas
|
|
WHERE favorite = 1
|
|
AND source = :sourceId;
|
|
|
|
getDuplicateLibraryManga:
|
|
SELECT *
|
|
FROM mangas
|
|
WHERE favorite = 1
|
|
AND LOWER(title) = :title
|
|
AND source != :source
|
|
LIMIT 1;
|
|
|
|
resetViewerFlags:
|
|
UPDATE mangas
|
|
SET viewer = 0;
|
|
|
|
getSourceIdsWithNonLibraryManga:
|
|
SELECT source, COUNT(*) AS manga_count
|
|
FROM mangas
|
|
WHERE favorite = 0
|
|
GROUP BY source;
|
|
|
|
deleteMangasNotInLibraryBySourceIds:
|
|
DELETE FROM mangas
|
|
WHERE favorite = 0 AND source IN :sourceIds;
|
|
|
|
insert:
|
|
INSERT INTO mangas(source,url,artist,author,description,genre,title,status,thumbnail_url,favorite,last_update,next_update,initialized,viewer,chapter_flags,cover_last_modified,date_added,update_strategy)
|
|
VALUES (:source,:url,:artist,:author,:description,:genre,:title,:status,:thumbnailUrl,:favorite,:lastUpdate,:nextUpdate,:initialized,:viewerFlags,:chapterFlags,:coverLastModified,:dateAdded,:updateStrategy);
|
|
|
|
update:
|
|
UPDATE mangas SET
|
|
source = coalesce(:source, source),
|
|
url = coalesce(:url, url),
|
|
artist = coalesce(:artist, artist),
|
|
author = coalesce(:author, author),
|
|
description = coalesce(:description, description),
|
|
genre = coalesce(:genre, genre),
|
|
title = coalesce(:title, title),
|
|
status = coalesce(:status, status),
|
|
thumbnail_url = coalesce(:thumbnailUrl, thumbnail_url),
|
|
favorite = coalesce(:favorite, favorite),
|
|
last_update = coalesce(:lastUpdate, last_update),
|
|
initialized = coalesce(:initialized, initialized),
|
|
viewer = coalesce(:viewer, viewer),
|
|
chapter_flags = coalesce(:chapterFlags, chapter_flags),
|
|
cover_last_modified = coalesce(:coverLastModified, cover_last_modified),
|
|
date_added = coalesce(:dateAdded, date_added),
|
|
update_strategy = coalesce(:updateStrategy, update_strategy)
|
|
WHERE _id = :mangaId;
|
|
|
|
selectLastInsertedRowId:
|
|
SELECT last_insert_rowid();
|