From b2292a50ee667d94a06cc23418d95d9ba9ec0b5a Mon Sep 17 00:00:00 2001 From: PoonHarpoon <52467605+PoonHarpoon@users.noreply.github.com> Date: Wed, 4 Nov 2026 06:02:21 +0000 Subject: [PATCH] Keep reading statistics when migrating to another source Migration moved favourites, history and tracking to the new manga id but left the stats rows on the old one, so the migrated title showed no reading time and the rows were lost once the old history was purged. Move them along with the history. Fixes #127 --- .../landwarderer/futon/alternatives/domain/MigrateUseCase.kt | 1 + .../kotlin/io/github/landwarderer/futon/stats/data/StatsDao.kt | 3 +++ 2 files changed, 4 insertions(+) diff --git a/app/src/main/kotlin/io/github/landwarderer/futon/alternatives/domain/MigrateUseCase.kt b/app/src/main/kotlin/io/github/landwarderer/futon/alternatives/domain/MigrateUseCase.kt index 996d7fb391..8d02523f1e 100644 --- a/app/src/main/kotlin/io/github/landwarderer/futon/alternatives/domain/MigrateUseCase.kt +++ b/app/src/main/kotlin/io/github/landwarderer/futon/alternatives/domain/MigrateUseCase.kt @@ -67,6 +67,7 @@ constructor( val newHistory = makeNewHistory(oldDetails, newDetails, oldHistory) historyDao.delete(oldDetails.id) historyDao.upsert(newHistory) + database.getStatsDao().move(oldDetails.id, newDetails.id) newHistory } else { null diff --git a/app/src/main/kotlin/io/github/landwarderer/futon/stats/data/StatsDao.kt b/app/src/main/kotlin/io/github/landwarderer/futon/stats/data/StatsDao.kt index ce5afed87c..bfc87cf4c5 100644 --- a/app/src/main/kotlin/io/github/landwarderer/futon/stats/data/StatsDao.kt +++ b/app/src/main/kotlin/io/github/landwarderer/futon/stats/data/StatsDao.kt @@ -34,6 +34,9 @@ abstract class StatsDao { @Query("SELECT COUNT(*) FROM stats WHERE manga_id = :mangaId") abstract fun observeRowCount(mangaId: Long): Flow + @Query("UPDATE OR IGNORE stats SET manga_id = :newMangaId WHERE manga_id = :oldMangaId") + abstract suspend fun move(oldMangaId: Long, newMangaId: Long) + @Upsert abstract suspend fun upsert(entity: StatsEntity)