Database changes to support library syncing (#9683)
* feat: added migrations. * feat: create triggers, account for new installs. * feat: update mappers to include the new field. * feat: update backupManga and backupChapter. Include the new fields to be backed up as well. * feat: add sql query to fetch all manga with `last_favorited_at` field. * feat: version bump. * chore: revert and refactor. * chore: forgot to lower case the field name. * chore: added getAllManga query as well renamed `fetchMangaWithLastFavorite` to `getMangasWithFavoriteTimestamp` * chore: oops that's not meant to be there. * feat: back fill and set last_modified_at to not null. * chore: remove redundant triggers. * fix: build error, accidentally removed insert. * fix: build error, accidentally removed insert. * refactor: review pointer, make fields not null. (cherry picked from commit a577f5534f31086174b1cc851d8b489d69f557e8) # Conflicts: # app/build.gradle.kts # app/src/main/java/eu/kanade/tachiyomi/data/backup/models/BackupManga.kt # data/src/main/java/tachiyomi/data/manga/MangaMapper.kt # data/src/main/sqldelight/tachiyomi/data/mangas.sq # data/src/main/sqldelight/tachiyomi/migrations/25.sqm # domain/src/main/java/tachiyomi/domain/manga/model/Manga.kt
This commit is contained in:
@@ -30,13 +30,15 @@ private val mapper = { cursor: SqlCursor ->
|
||||
filtered_scanlators = cursor.getString(18)?.let(listOfStringsAndAdapter::decode),
|
||||
update_strategy = updateStrategyAdapter.decode(cursor.getLong(19)!!),
|
||||
calculate_interval = cursor.getLong(20)!!,
|
||||
totalCount = cursor.getLong(21)!!,
|
||||
readCount = cursor.getLong(22)!!,
|
||||
latestUpload = cursor.getLong(23)!!,
|
||||
chapterFetchedAt = cursor.getLong(24)!!,
|
||||
lastRead = cursor.getLong(25)!!,
|
||||
bookmarkCount = cursor.getLong(26)!!,
|
||||
category = cursor.getLong(27)!!,
|
||||
last_modified_at = cursor.getLong(21)!!,
|
||||
favorite_modified_at = cursor.getLong(22)!!,
|
||||
totalCount = cursor.getLong(23)!!,
|
||||
readCount = cursor.getLong(24)!!,
|
||||
latestUpload = cursor.getLong(25)!!,
|
||||
chapterFetchedAt = cursor.getLong(26)!!,
|
||||
lastRead = cursor.getLong(27)!!,
|
||||
bookmarkCount = cursor.getLong(28)!!,
|
||||
category = cursor.getLong(29)!!,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ package tachiyomi.data.chapter
|
||||
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
|
||||
val chapterMapper: (Long, Long, String, String, String?, Boolean, Boolean, Long, Float, Long, Long, Long) -> Chapter =
|
||||
{ id, mangaId, url, name, scanlator, read, bookmark, lastPageRead, chapterNumber, sourceOrder, dateFetch, dateUpload ->
|
||||
val chapterMapper: (Long, Long, String, String, String?, Boolean, Boolean, Long, Float, Long, Long, Long, Long) -> Chapter =
|
||||
{ id, mangaId, url, name, scanlator, read, bookmark, lastPageRead, chapterNumber, sourceOrder, dateFetch, dateUpload, lastModifiedAt ->
|
||||
Chapter(
|
||||
id = id,
|
||||
mangaId = mangaId,
|
||||
@@ -17,5 +17,6 @@ val chapterMapper: (Long, Long, String, String, String?, Boolean, Boolean, Long,
|
||||
dateUpload = dateUpload,
|
||||
chapterNumber = chapterNumber,
|
||||
scanlator = scanlator,
|
||||
lastModifiedAt = lastModifiedAt,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import tachiyomi.domain.library.model.LibraryManga
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.view.LibraryView
|
||||
|
||||
val mangaMapper: (Long, Long, String, String?, String?, String?, List<String>?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long, List<String>?, UpdateStrategy, Long) -> Manga =
|
||||
{ id, source, url, artist, author, description, genre, title, status, thumbnailUrl, favorite, lastUpdate, nextUpdate, initialized, viewerFlags, chapterFlags, coverLastModified, dateAdded, filteredScanlators, updateStrategy, calculateInterval ->
|
||||
val mangaMapper: (Long, Long, String, String?, String?, String?, List<String>?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long, List<String>?, UpdateStrategy, Long, Long, Long?) -> Manga =
|
||||
{ id, source, url, artist, author, description, genre, title, status, thumbnailUrl, favorite, lastUpdate, nextUpdate, initialized, viewerFlags, chapterFlags, coverLastModified, dateAdded, filteredScanlators, updateStrategy, calculateInterval, lastModifiedAt, favoriteModifiedAt ->
|
||||
Manga(
|
||||
id = id,
|
||||
source = source,
|
||||
@@ -33,11 +33,13 @@ val mangaMapper: (Long, Long, String, String?, String?, String?, List<String>?,
|
||||
// SY -->
|
||||
filteredScanlators = filteredScanlators,
|
||||
// SY <--
|
||||
lastModifiedAt = lastModifiedAt,
|
||||
favoriteModifiedAt = favoriteModifiedAt,
|
||||
)
|
||||
}
|
||||
|
||||
val libraryManga: (Long, Long, String, String?, String?, String?, List<String>?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long, List<String>?, UpdateStrategy, Long, Long, Long, Long, Long, Long, Long, Long) -> LibraryManga =
|
||||
{ id, source, url, artist, author, description, genre, title, status, thumbnailUrl, favorite, lastUpdate, nextUpdate, initialized, viewerFlags, chapterFlags, coverLastModified, dateAdded, filteredScanlators, updateStrategy, calculateInterval, totalCount, readCount, latestUpload, chapterFetchedAt, lastRead, bookmarkCount, category ->
|
||||
val libraryManga: (Long, Long, String, String?, String?, String?, List<String>?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long, List<String>?, UpdateStrategy, Long, Long, Long?, Long, Long, Long, Long, Long, Long, Long) -> LibraryManga =
|
||||
{ id, source, url, artist, author, description, genre, title, status, thumbnailUrl, favorite, lastUpdate, nextUpdate, initialized, viewerFlags, chapterFlags, coverLastModified, dateAdded, filteredScanlators, updateStrategy, calculateInterval, lastModifiedAt, favoriteModifiedAt, totalCount, readCount, latestUpload, chapterFetchedAt, lastRead, bookmarkCount, category ->
|
||||
LibraryManga(
|
||||
manga = mangaMapper(
|
||||
id,
|
||||
@@ -63,6 +65,8 @@ val libraryManga: (Long, Long, String, String?, String?, String?, List<String>?,
|
||||
// SY <--
|
||||
updateStrategy,
|
||||
calculateInterval,
|
||||
lastModifiedAt,
|
||||
favoriteModifiedAt,
|
||||
),
|
||||
category = category,
|
||||
totalChapters = totalCount,
|
||||
@@ -98,6 +102,8 @@ val libraryViewMapper: (LibraryView) -> LibraryManga = {
|
||||
initialized = it.initialized,
|
||||
filteredScanlators = it.filtered_scanlators,
|
||||
calculateInterval = it.calculate_interval.toInt(),
|
||||
lastModifiedAt = it.last_modified_at,
|
||||
favoriteModifiedAt = it.favorite_modified_at,
|
||||
),
|
||||
it.category,
|
||||
it.totalCount,
|
||||
|
||||
Reference in New Issue
Block a user