add MangaTable.lastFetchedAt and ChapterTable.chaptersLastFetchedAt (#431)

* Add lastFetchedAt and chaptersLastFetchedAt columns to manga

* Update lastFetchedAt columns when data are fetched from source

* Add age and chaptersAge fields to MangaDataClass

* Replace two migrations with single migration
This commit is contained in:
Valter Martinek
2022-10-30 17:46:23 +01:00
committed by GitHub
parent 23f0876c00
commit 0fa2834d25
6 changed files with 46 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ package suwayomi.tachidesk.manga.model.dataclass
import suwayomi.tachidesk.manga.impl.util.lang.trimAll
import suwayomi.tachidesk.manga.model.table.MangaStatus
import java.time.Instant
data class MangaDataClass(
val id: Int,
@@ -33,11 +34,16 @@ data class MangaDataClass(
val meta: Map<String, String> = emptyMap(),
val realUrl: String? = null,
var lastFetchedAt: Long? = 0,
var chaptersLastFetchedAt: Long? = 0,
val freshData: Boolean = false,
var unreadCount: Int? = null,
var downloadCount: Int? = null,
var chapterCount: Int? = null
var chapterCount: Int? = null,
val age: Long? = if (lastFetchedAt == null) 0 else Instant.now().epochSecond.minus(lastFetchedAt),
val chaptersAge: Long? = if (chaptersLastFetchedAt == null) null else Instant.now().epochSecond.minus(chaptersLastFetchedAt)
)
data class PagedMangaListDataClass(

View File

@@ -38,6 +38,9 @@ object MangaTable : IntIdTable() {
/** the real url of a manga used for the "open in WebView" feature */
val realUrl = varchar("real_url", 2048).nullable()
val lastFetchedAt = long("last_fetched_at").default(0)
val chaptersLastFetchedAt = long("chapters_last_fetched_at").default(0)
}
fun MangaTable.toDataClass(mangaEntry: ResultRow) =
@@ -59,7 +62,9 @@ fun MangaTable.toDataClass(mangaEntry: ResultRow) =
mangaEntry[inLibrary],
mangaEntry[inLibraryAt],
meta = getMangaMetaMap(mangaEntry[id].value),
realUrl = mangaEntry[realUrl]
realUrl = mangaEntry[realUrl],
lastFetchedAt = mangaEntry[lastFetchedAt],
chaptersLastFetchedAt = mangaEntry[chaptersLastFetchedAt]
)
enum class MangaStatus(val value: Int) {