mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 01:35:10 +01:00
Cleanup data layer (#7450)
This commit is contained in:
parent
68697e59d7
commit
069bd90c0f
@ -41,39 +41,28 @@ class ChapterRepositoryImpl(
|
||||
}
|
||||
|
||||
override suspend fun update(chapterUpdate: ChapterUpdate) {
|
||||
handler.await {
|
||||
chaptersQueries.update(
|
||||
chapterUpdate.mangaId,
|
||||
chapterUpdate.url,
|
||||
chapterUpdate.name,
|
||||
chapterUpdate.scanlator,
|
||||
chapterUpdate.read?.toLong(),
|
||||
chapterUpdate.bookmark?.toLong(),
|
||||
chapterUpdate.lastPageRead,
|
||||
chapterUpdate.chapterNumber?.toDouble(),
|
||||
chapterUpdate.sourceOrder,
|
||||
chapterUpdate.dateFetch,
|
||||
chapterUpdate.dateUpload,
|
||||
chapterId = chapterUpdate.id,
|
||||
)
|
||||
}
|
||||
partialUpdate(chapterUpdate)
|
||||
}
|
||||
|
||||
override suspend fun updateAll(chapterUpdates: List<ChapterUpdate>) {
|
||||
partialUpdate(*chapterUpdates.toTypedArray())
|
||||
}
|
||||
|
||||
private suspend fun partialUpdate(vararg chapterUpdates: ChapterUpdate) {
|
||||
handler.await(inTransaction = true) {
|
||||
chapterUpdates.forEach { chapterUpdate ->
|
||||
chaptersQueries.update(
|
||||
chapterUpdate.mangaId,
|
||||
chapterUpdate.url,
|
||||
chapterUpdate.name,
|
||||
chapterUpdate.scanlator,
|
||||
chapterUpdate.read?.toLong(),
|
||||
chapterUpdate.bookmark?.toLong(),
|
||||
chapterUpdate.lastPageRead,
|
||||
chapterUpdate.chapterNumber?.toDouble(),
|
||||
chapterUpdate.sourceOrder,
|
||||
chapterUpdate.dateFetch,
|
||||
chapterUpdate.dateUpload,
|
||||
mangaId = chapterUpdate.mangaId,
|
||||
url = chapterUpdate.url,
|
||||
name = chapterUpdate.name,
|
||||
scanlator = chapterUpdate.scanlator,
|
||||
read = chapterUpdate.read?.toLong(),
|
||||
bookmark = chapterUpdate.bookmark?.toLong(),
|
||||
lastPageRead = chapterUpdate.lastPageRead,
|
||||
chapterNumber = chapterUpdate.chapterNumber?.toDouble(),
|
||||
sourceOrder = chapterUpdate.sourceOrder,
|
||||
dateFetch = chapterUpdate.dateFetch,
|
||||
dateUpload = chapterUpdate.dateUpload,
|
||||
chapterId = chapterUpdate.id,
|
||||
)
|
||||
}
|
||||
|
@ -79,15 +79,15 @@ class MangaRepositoryImpl(
|
||||
genre = manga.genre,
|
||||
title = manga.title,
|
||||
status = manga.status,
|
||||
thumbnail_url = manga.thumbnailUrl,
|
||||
thumbnailUrl = manga.thumbnailUrl,
|
||||
favorite = manga.favorite,
|
||||
last_update = manga.lastUpdate,
|
||||
next_update = null,
|
||||
lastUpdate = manga.lastUpdate,
|
||||
nextUpdate = null,
|
||||
initialized = manga.initialized,
|
||||
viewer = manga.viewerFlags,
|
||||
chapter_flags = manga.chapterFlags,
|
||||
cover_last_modified = manga.coverLastModified,
|
||||
date_added = manga.dateAdded,
|
||||
viewerFlags = manga.viewerFlags,
|
||||
chapterFlags = manga.chapterFlags,
|
||||
coverLastModified = manga.coverLastModified,
|
||||
dateAdded = manga.dateAdded,
|
||||
)
|
||||
mangasQueries.selectLastInsertedRowId()
|
||||
}
|
||||
|
@ -37,27 +37,16 @@ class TrackRepositoryImpl(
|
||||
}
|
||||
|
||||
override suspend fun insert(track: Track) {
|
||||
handler.await {
|
||||
manga_syncQueries.insert(
|
||||
mangaId = track.mangaId,
|
||||
syncId = track.syncId,
|
||||
remoteId = track.remoteId,
|
||||
libraryId = track.libraryId,
|
||||
title = track.title,
|
||||
lastChapterRead = track.lastChapterRead,
|
||||
totalChapters = track.totalChapters,
|
||||
status = track.status,
|
||||
score = track.score,
|
||||
remoteUrl = track.remoteUrl,
|
||||
startDate = track.startDate,
|
||||
finishDate = track.finishDate,
|
||||
)
|
||||
}
|
||||
insertValues(track)
|
||||
}
|
||||
|
||||
override suspend fun insertAll(tracks: List<Track>) {
|
||||
insertValues(*tracks.toTypedArray())
|
||||
}
|
||||
|
||||
private suspend fun insertValues(vararg values: Track) {
|
||||
handler.await(inTransaction = true) {
|
||||
tracks.forEach { mangaTrack ->
|
||||
values.forEach { mangaTrack ->
|
||||
manga_syncQueries.insert(
|
||||
mangaId = mangaTrack.mangaId,
|
||||
syncId = mangaTrack.syncId,
|
||||
|
@ -86,15 +86,15 @@ abstract class AbstractBackupManager(protected val context: Context) {
|
||||
genre = manga.getGenres(),
|
||||
title = manga.title,
|
||||
status = manga.status.toLong(),
|
||||
thumbnail_url = manga.thumbnail_url,
|
||||
thumbnailUrl = manga.thumbnail_url,
|
||||
favorite = manga.favorite,
|
||||
last_update = manga.last_update,
|
||||
next_update = 0L,
|
||||
lastUpdate = manga.last_update,
|
||||
nextUpdate = 0L,
|
||||
initialized = manga.initialized,
|
||||
viewer = manga.viewer_flags.toLong(),
|
||||
chapter_flags = manga.chapter_flags.toLong(),
|
||||
cover_last_modified = manga.cover_last_modified,
|
||||
date_added = manga.date_added,
|
||||
viewerFlags = manga.viewer_flags.toLong(),
|
||||
chapterFlags = manga.chapter_flags.toLong(),
|
||||
coverLastModified = manga.cover_last_modified,
|
||||
dateAdded = manga.date_added,
|
||||
)
|
||||
mangasQueries.selectLastInsertedRowId()
|
||||
}
|
||||
|
@ -25,10 +25,6 @@ CREATE TABLE mangas(
|
||||
CREATE INDEX library_favorite_index ON mangas(favorite) WHERE favorite = 1;
|
||||
CREATE INDEX mangas_url_index ON mangas(url);
|
||||
|
||||
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)
|
||||
VALUES (:source,:url,:artist,:author,:description,:genre,:title,:status,:thumbnail_url,:favorite,:last_update,:next_update,:initialized,:viewer,:chapter_flags,:cover_last_modified,:date_added);
|
||||
|
||||
getMangaById:
|
||||
SELECT *
|
||||
FROM mangas
|
||||
@ -145,43 +141,9 @@ deleteMangasNotInLibraryBySourceIds:
|
||||
DELETE FROM mangas
|
||||
WHERE favorite = 0 AND source IN :sourceIds;
|
||||
|
||||
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
|
||||
) VALUES (
|
||||
:source,
|
||||
:url,
|
||||
:artist,
|
||||
:author,
|
||||
:description,
|
||||
:genre,
|
||||
:title,
|
||||
:status,
|
||||
:thumbnailUrl,
|
||||
:favorite,
|
||||
:lastUpdate,
|
||||
0,
|
||||
:initialized,
|
||||
:viewerFlags,
|
||||
:chapterFlags,
|
||||
:coverLastModified,
|
||||
:dateAdded
|
||||
);
|
||||
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)
|
||||
VALUES (:source,:url,:artist,:author,:description,:genre,:title,:status,:thumbnailUrl,:favorite,:lastUpdate,:nextUpdate,:initialized,:viewerFlags,:chapterFlags,:coverLastModified,:dateAdded);
|
||||
|
||||
update:
|
||||
UPDATE mangas SET
|
||||
|
Loading…
Reference in New Issue
Block a user