mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-18 02:03:33 -05:00
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:
@@ -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(
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user