mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-16 13:48:09 -07:00
Remove unused sync scaffold
Drops the unused version, is_syncing and last_modified_at columns and their triggers.
This commit is contained in:
@@ -41,7 +41,6 @@ class ChapterRepositoryImpl(
|
||||
chapter.sourceOrder,
|
||||
chapter.dateFetch,
|
||||
chapter.dateUpload,
|
||||
chapter.version,
|
||||
chapter.memo,
|
||||
)
|
||||
.awaitAsOne()
|
||||
@@ -78,8 +77,6 @@ class ChapterRepositoryImpl(
|
||||
dateFetch = chapterUpdate.dateFetch,
|
||||
dateUpload = chapterUpdate.dateUpload,
|
||||
chapterId = chapterUpdate.id,
|
||||
version = chapterUpdate.version,
|
||||
isSyncing = 0,
|
||||
memo = chapterUpdate.memo,
|
||||
)
|
||||
}
|
||||
@@ -150,9 +147,6 @@ class ChapterRepositoryImpl(
|
||||
sourceOrder: Long,
|
||||
dateFetch: Long,
|
||||
dateUpload: Long,
|
||||
lastModifiedAt: Long,
|
||||
version: Long,
|
||||
isSyncing: Long,
|
||||
memo: JsonObject,
|
||||
): Chapter = Chapter(
|
||||
id = id,
|
||||
@@ -167,8 +161,6 @@ class ChapterRepositoryImpl(
|
||||
dateUpload = dateUpload,
|
||||
chapterNumber = chapterNumber,
|
||||
scanlator = scanlator,
|
||||
lastModifiedAt = lastModifiedAt,
|
||||
version = version,
|
||||
memo = memo,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.model.MangaWithChapterCount
|
||||
|
||||
object MangaMapper {
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun mapManga(
|
||||
id: Long,
|
||||
source: Long,
|
||||
@@ -29,10 +28,7 @@ object MangaMapper {
|
||||
dateAdded: Long,
|
||||
updateStrategy: UpdateStrategy,
|
||||
calculateInterval: Long,
|
||||
lastModifiedAt: Long,
|
||||
favoriteModifiedAt: Long?,
|
||||
version: Long,
|
||||
isSyncing: Long,
|
||||
notes: String,
|
||||
memo: JsonObject,
|
||||
): Manga = Manga(
|
||||
@@ -56,9 +52,7 @@ object MangaMapper {
|
||||
thumbnailUrl = thumbnailUrl,
|
||||
updateStrategy = updateStrategy,
|
||||
initialized = initialized,
|
||||
lastModifiedAt = lastModifiedAt,
|
||||
favoriteModifiedAt = favoriteModifiedAt,
|
||||
version = version,
|
||||
notes = notes,
|
||||
memo = memo,
|
||||
)
|
||||
@@ -84,10 +78,7 @@ object MangaMapper {
|
||||
dateAdded: Long,
|
||||
updateStrategy: UpdateStrategy,
|
||||
calculateInterval: Long,
|
||||
lastModifiedAt: Long,
|
||||
favoriteModifiedAt: Long?,
|
||||
version: Long,
|
||||
isSyncing: Long,
|
||||
notes: String,
|
||||
memo: JsonObject,
|
||||
totalCount: Long,
|
||||
@@ -119,10 +110,7 @@ object MangaMapper {
|
||||
dateAdded,
|
||||
updateStrategy,
|
||||
calculateInterval,
|
||||
lastModifiedAt,
|
||||
favoriteModifiedAt,
|
||||
version,
|
||||
isSyncing,
|
||||
notes,
|
||||
memo,
|
||||
),
|
||||
@@ -156,10 +144,7 @@ object MangaMapper {
|
||||
dateAdded: Long,
|
||||
updateStrategy: UpdateStrategy,
|
||||
calculateInterval: Long,
|
||||
lastModifiedAt: Long,
|
||||
favoriteModifiedAt: Long?,
|
||||
version: Long,
|
||||
isSyncing: Long,
|
||||
notes: String,
|
||||
memo: JsonObject,
|
||||
totalCount: Long,
|
||||
@@ -185,10 +170,7 @@ object MangaMapper {
|
||||
dateAdded,
|
||||
updateStrategy,
|
||||
calculateInterval,
|
||||
lastModifiedAt,
|
||||
favoriteModifiedAt,
|
||||
version,
|
||||
isSyncing,
|
||||
notes,
|
||||
memo,
|
||||
),
|
||||
|
||||
@@ -174,7 +174,6 @@ class MangaRepositoryImpl(
|
||||
coverLastModified = it.coverLastModified,
|
||||
dateAdded = it.dateAdded,
|
||||
updateStrategy = it.updateStrategy,
|
||||
version = it.version,
|
||||
memo = it.memo,
|
||||
updateTitle = it.title.isNotBlank(),
|
||||
updateCover = !it.thumbnailUrl.isNullOrBlank(),
|
||||
@@ -210,8 +209,6 @@ class MangaRepositoryImpl(
|
||||
dateAdded = value.dateAdded,
|
||||
mangaId = value.id,
|
||||
updateStrategy = value.updateStrategy,
|
||||
version = value.version,
|
||||
isSyncing = 0,
|
||||
notes = value.notes,
|
||||
memo = value.memo,
|
||||
)
|
||||
|
||||
@@ -14,9 +14,6 @@ CREATE TABLE chapters(
|
||||
source_order INTEGER NOT NULL,
|
||||
date_fetch INTEGER NOT NULL,
|
||||
date_upload INTEGER NOT NULL,
|
||||
last_modified_at INTEGER NOT NULL DEFAULT 0,
|
||||
version INTEGER NOT NULL DEFAULT 0,
|
||||
is_syncing INTEGER NOT NULL DEFAULT 0,
|
||||
memo BLOB AS JsonObject NOT NULL DEFAULT '{}',
|
||||
FOREIGN KEY(manga_id) REFERENCES mangas (_id)
|
||||
ON DELETE CASCADE
|
||||
@@ -26,30 +23,6 @@ CREATE INDEX chapters_manga_id_index ON chapters(manga_id);
|
||||
CREATE INDEX chapters_unread_by_manga_index ON chapters(manga_id, read) WHERE read = 0;
|
||||
CREATE INDEX idx_chapters_url ON chapters(url);
|
||||
|
||||
CREATE TRIGGER update_last_modified_at_chapters
|
||||
AFTER UPDATE ON chapters
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE chapters
|
||||
SET last_modified_at = strftime('%s', 'now')
|
||||
WHERE _id = new._id;
|
||||
END;
|
||||
|
||||
CREATE TRIGGER update_chapter_and_manga_version AFTER UPDATE ON chapters
|
||||
WHEN new.is_syncing = 0 AND (
|
||||
new.read != old.read OR
|
||||
new.bookmark != old.bookmark OR
|
||||
new.last_page_read != old.last_page_read
|
||||
)
|
||||
BEGIN
|
||||
-- Update the chapter version
|
||||
UPDATE chapters SET version = version + 1
|
||||
WHERE _id = new._id;
|
||||
|
||||
-- Update the manga version
|
||||
UPDATE mangas SET version = version + 1
|
||||
WHERE _id = new.manga_id AND (SELECT is_syncing FROM mangas WHERE _id = new.manga_id) = 0;
|
||||
END;
|
||||
|
||||
getChapterById:
|
||||
SELECT *
|
||||
@@ -95,18 +68,13 @@ removeChaptersWithIds:
|
||||
DELETE FROM chapters
|
||||
WHERE _id IN :chapterIds;
|
||||
|
||||
resetIsSyncing:
|
||||
UPDATE chapters
|
||||
SET is_syncing = 0
|
||||
WHERE is_syncing = 1;
|
||||
|
||||
insert:
|
||||
INSERT INTO chapters(manga_id, url, name, scanlator, read, bookmark, last_page_read, chapter_number, source_order, date_fetch, date_upload, last_modified_at, version, is_syncing, memo)
|
||||
VALUES (:mangaId, :url, :name, :scanlator, :read, :bookmark, :lastPageRead, :chapterNumber, :sourceOrder, :dateFetch, :dateUpload, 0, :version, 0, :memo);
|
||||
INSERT INTO chapters(manga_id, url, name, scanlator, read, bookmark, last_page_read, chapter_number, source_order, date_fetch, date_upload, memo)
|
||||
VALUES (:mangaId, :url, :name, :scanlator, :read, :bookmark, :lastPageRead, :chapterNumber, :sourceOrder, :dateFetch, :dateUpload, :memo);
|
||||
|
||||
insertReturningId:
|
||||
INSERT INTO chapters(manga_id, url, name, scanlator, read, bookmark, last_page_read, chapter_number, source_order, date_fetch, date_upload, last_modified_at, version, is_syncing, memo)
|
||||
VALUES (:mangaId, :url, :name, :scanlator, :read, :bookmark, :lastPageRead, :chapterNumber, :sourceOrder, :dateFetch, :dateUpload, 0, :version, 0, :memo)
|
||||
INSERT INTO chapters(manga_id, url, name, scanlator, read, bookmark, last_page_read, chapter_number, source_order, date_fetch, date_upload, memo)
|
||||
VALUES (:mangaId, :url, :name, :scanlator, :read, :bookmark, :lastPageRead, :chapterNumber, :sourceOrder, :dateFetch, :dateUpload, :memo)
|
||||
RETURNING _id;
|
||||
|
||||
update:
|
||||
@@ -122,7 +90,5 @@ SET manga_id = coalesce(:mangaId, manga_id),
|
||||
source_order = coalesce(:sourceOrder, source_order),
|
||||
date_fetch = coalesce(:dateFetch, date_fetch),
|
||||
date_upload = coalesce(:dateUpload, date_upload),
|
||||
version = coalesce(:version, version),
|
||||
is_syncing = coalesce(:isSyncing, is_syncing),
|
||||
memo = coalesce(:memo, memo)
|
||||
WHERE _id = :chapterId;
|
||||
|
||||
@@ -25,10 +25,7 @@ CREATE TABLE mangas(
|
||||
date_added INTEGER NOT NULL,
|
||||
update_strategy INTEGER AS UpdateStrategy NOT NULL DEFAULT 0,
|
||||
calculate_interval INTEGER DEFAULT 0 NOT NULL,
|
||||
last_modified_at INTEGER NOT NULL DEFAULT 0,
|
||||
favorite_modified_at INTEGER,
|
||||
version INTEGER NOT NULL DEFAULT 0,
|
||||
is_syncing INTEGER NOT NULL DEFAULT 0,
|
||||
notes TEXT NOT NULL DEFAULT "",
|
||||
memo BLOB AS JsonObject NOT NULL DEFAULT '{}'
|
||||
);
|
||||
@@ -45,25 +42,6 @@ BEGIN
|
||||
WHERE _id = new._id;
|
||||
END;
|
||||
|
||||
CREATE TRIGGER update_last_modified_at_mangas
|
||||
AFTER UPDATE ON mangas
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
UPDATE mangas
|
||||
SET last_modified_at = strftime('%s', 'now')
|
||||
WHERE _id = new._id;
|
||||
END;
|
||||
|
||||
CREATE TRIGGER update_manga_version AFTER UPDATE ON mangas
|
||||
BEGIN
|
||||
UPDATE mangas SET version = version + 1
|
||||
WHERE _id = new._id AND new.is_syncing = 0 AND (
|
||||
new.url != old.url OR
|
||||
new.description != old.description OR
|
||||
new.favorite != old.favorite
|
||||
);
|
||||
END;
|
||||
|
||||
getMangaById:
|
||||
SELECT *
|
||||
FROM mangas
|
||||
@@ -198,11 +176,6 @@ resetViewerFlags:
|
||||
UPDATE mangas
|
||||
SET viewer = 0;
|
||||
|
||||
resetIsSyncing:
|
||||
UPDATE mangas
|
||||
SET is_syncing = 0
|
||||
WHERE is_syncing = 1;
|
||||
|
||||
getSourceIdsWithNonLibraryManga:
|
||||
SELECT source, COUNT(*) AS manga_count
|
||||
FROM mangas
|
||||
@@ -224,8 +197,8 @@ AND (
|
||||
);
|
||||
|
||||
insertReturningId:
|
||||
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, calculate_interval, last_modified_at, version, notes, memo)
|
||||
VALUES (:source, :url, :artist, :author, :description, :genre, :title, :status, :thumbnailUrl, :favorite, :lastUpdate, :nextUpdate, :initialized, :viewerFlags, :chapterFlags, :coverLastModified, :dateAdded, :updateStrategy, :calculateInterval, 0, :version, :notes, :memo)
|
||||
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, calculate_interval, notes, memo)
|
||||
VALUES (:source, :url, :artist, :author, :description, :genre, :title, :status, :thumbnailUrl, :favorite, :lastUpdate, :nextUpdate, :initialized, :viewerFlags, :chapterFlags, :coverLastModified, :dateAdded, :updateStrategy, :calculateInterval, :notes, :memo)
|
||||
RETURNING _id;
|
||||
|
||||
update:
|
||||
@@ -249,8 +222,6 @@ UPDATE mangas SET
|
||||
date_added = coalesce(:dateAdded, date_added),
|
||||
update_strategy = coalesce(:updateStrategy, update_strategy),
|
||||
calculate_interval = coalesce(:calculateInterval, calculate_interval),
|
||||
version = coalesce(:version, version),
|
||||
is_syncing = coalesce(:isSyncing, is_syncing),
|
||||
notes = coalesce(:notes, notes),
|
||||
memo = coalesce(:memo, memo)
|
||||
WHERE _id = :mangaId;
|
||||
@@ -260,12 +231,12 @@ insertNetworkManga {
|
||||
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, calculate_interval, last_modified_at, version, memo
|
||||
update_strategy, calculate_interval, memo
|
||||
)
|
||||
SELECT
|
||||
:source, :url, :artist, :author, :description, :genre, :title, :status, :thumbnailUrl, :favorite,
|
||||
:lastUpdate, :nextUpdate, :initialized, :viewerFlags, :chapterFlags, :coverLastModified, :dateAdded,
|
||||
:updateStrategy, :calculateInterval, 0, :version, :memo
|
||||
:updateStrategy, :calculateInterval, :memo
|
||||
WHERE NOT EXISTS(SELECT 0 FROM mangas WHERE source = :source AND url = :url);
|
||||
|
||||
-- Update the relevant details if applicable and not favorite
|
||||
|
||||
@@ -11,13 +11,6 @@ CREATE TABLE mangas_categories(
|
||||
CREATE INDEX idx_mangas_categories_manga_id ON mangas_categories(manga_id);
|
||||
CREATE INDEX idx_mangas_categories_category_id ON mangas_categories(category_id);
|
||||
|
||||
CREATE TRIGGER insert_manga_category_update_version AFTER INSERT ON mangas_categories
|
||||
BEGIN
|
||||
UPDATE mangas
|
||||
SET version = version + 1
|
||||
WHERE _id = new.manga_id AND (SELECT is_syncing FROM mangas WHERE _id = new.manga_id) = 0;
|
||||
END;
|
||||
|
||||
insert:
|
||||
INSERT INTO mangas_categories(manga_id, category_id)
|
||||
VALUES (:mangaId, :categoryId);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
-- Remove the sync scaffolding: version, is_syncing and last_modified_at.
|
||||
|
||||
DROP TRIGGER update_manga_version;
|
||||
DROP TRIGGER update_last_modified_at_mangas;
|
||||
DROP TRIGGER update_chapter_and_manga_version;
|
||||
DROP TRIGGER update_last_modified_at_chapters;
|
||||
DROP TRIGGER insert_manga_category_update_version;
|
||||
|
||||
ALTER TABLE mangas DROP COLUMN version;
|
||||
ALTER TABLE mangas DROP COLUMN is_syncing;
|
||||
ALTER TABLE mangas DROP COLUMN last_modified_at;
|
||||
|
||||
ALTER TABLE chapters DROP COLUMN version;
|
||||
ALTER TABLE chapters DROP COLUMN is_syncing;
|
||||
ALTER TABLE chapters DROP COLUMN last_modified_at;
|
||||
Reference in New Issue
Block a user