drop the artwork seed expiry

This commit is contained in:
austinried
2026-10-04 00:29:53 +00:00
parent a8804a78a0
commit 9c1ba2bea6
5 changed files with 7 additions and 36 deletions
@@ -12,7 +12,4 @@ interface ArtworkSeedDao {
@Upsert
suspend fun upsert(seed: ArtworkSeed)
@Query("DELETE FROM artwork_seeds WHERE updatedAt < :cutoff")
suspend fun pruneExpired(cutoff: Long)
}
@@ -39,10 +39,9 @@ val MIGRATION_3_4 =
override suspend fun migrate(connection: SQLiteConnection) {
connection.execSQL(
"CREATE TABLE IF NOT EXISTS `artwork_seeds` (`cacheKey` TEXT NOT NULL, " +
"`primary` INTEGER NOT NULL, `secondary` INTEGER, `updatedAt` INTEGER NOT NULL, " +
"`primary` INTEGER NOT NULL, `secondary` INTEGER, " +
"PRIMARY KEY(`cacheKey`))",
)
connection.execSQL("CREATE INDEX IF NOT EXISTS `index_artwork_seeds_updatedAt` ON `artwork_seeds` (`updatedAt`)")
}
}
@@ -209,12 +209,11 @@ data class PlaybackCursor(
val queuePosition: Long,
)
@Entity(tableName = "artwork_seeds", indices = [Index("updatedAt")])
@Entity(tableName = "artwork_seeds")
data class ArtworkSeed(
@PrimaryKey val cacheKey: String,
val primary: Int,
val secondary: Int?,
val updatedAt: Long,
)
class QueueKindConverter {
@@ -24,13 +24,6 @@ class ArtworkSeedRepository(
cacheKey: String,
seeds: Pair<Int, Int?>,
) {
val dao = db.artworkSeedDao()
val now = System.currentTimeMillis()
dao.upsert(ArtworkSeed(cacheKey, seeds.first, seeds.second, now))
dao.pruneExpired(now - MAX_AGE_MS)
}
private companion object {
const val MAX_AGE_MS = 30L * 24 * 60 * 60 * 1000
db.artworkSeedDao().upsert(ArtworkSeed(cacheKey, seeds.first, seeds.second))
}
}