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
+4 -21
View File
@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 4,
"identityHash": "9ee801b55a0e0e6a8b240d867c3a4e58",
"identityHash": "5c2180369cf0981302f79ec4e77187fd",
"entities": [
{
"tableName": "sources",
@@ -721,7 +721,7 @@
},
{
"tableName": "artwork_seeds",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`cacheKey` TEXT NOT NULL, `primary` INTEGER NOT NULL, `secondary` INTEGER, `updatedAt` INTEGER NOT NULL, PRIMARY KEY(`cacheKey`))",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`cacheKey` TEXT NOT NULL, `primary` INTEGER NOT NULL, `secondary` INTEGER, PRIMARY KEY(`cacheKey`))",
"fields": [
{
"fieldPath": "cacheKey",
@@ -739,12 +739,6 @@
"fieldPath": "secondary",
"columnName": "secondary",
"affinity": "INTEGER"
},
{
"fieldPath": "updatedAt",
"columnName": "updatedAt",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
@@ -752,23 +746,12 @@
"columnNames": [
"cacheKey"
]
},
"indices": [
{
"name": "index_artwork_seeds_updatedAt",
"unique": false,
"columnNames": [
"updatedAt"
],
"orders": [],
"createSql": "CREATE INDEX IF NOT EXISTS `index_artwork_seeds_updatedAt` ON `${TABLE_NAME}` (`updatedAt`)"
}
]
}
}
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '9ee801b55a0e0e6a8b240d867c3a4e58')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '5c2180369cf0981302f79ec4e77187fd')"
]
}
}
@@ -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))
}
}