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
+3 -20
View File
@@ -2,7 +2,7 @@
"formatVersion": 1, "formatVersion": 1,
"database": { "database": {
"version": 4, "version": 4,
"identityHash": "9ee801b55a0e0e6a8b240d867c3a4e58", "identityHash": "5c2180369cf0981302f79ec4e77187fd",
"entities": [ "entities": [
{ {
"tableName": "sources", "tableName": "sources",
@@ -721,7 +721,7 @@
}, },
{ {
"tableName": "artwork_seeds", "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": [ "fields": [
{ {
"fieldPath": "cacheKey", "fieldPath": "cacheKey",
@@ -739,12 +739,6 @@
"fieldPath": "secondary", "fieldPath": "secondary",
"columnName": "secondary", "columnName": "secondary",
"affinity": "INTEGER" "affinity": "INTEGER"
},
{
"fieldPath": "updatedAt",
"columnName": "updatedAt",
"affinity": "INTEGER",
"notNull": true
} }
], ],
"primaryKey": { "primaryKey": {
@@ -752,23 +746,12 @@
"columnNames": [ "columnNames": [
"cacheKey" "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": [ "setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", "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 @Upsert
suspend fun upsert(seed: ArtworkSeed) 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) { override suspend fun migrate(connection: SQLiteConnection) {
connection.execSQL( connection.execSQL(
"CREATE TABLE IF NOT EXISTS `artwork_seeds` (`cacheKey` TEXT NOT NULL, " + "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`))", "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, val queuePosition: Long,
) )
@Entity(tableName = "artwork_seeds", indices = [Index("updatedAt")]) @Entity(tableName = "artwork_seeds")
data class ArtworkSeed( data class ArtworkSeed(
@PrimaryKey val cacheKey: String, @PrimaryKey val cacheKey: String,
val primary: Int, val primary: Int,
val secondary: Int?, val secondary: Int?,
val updatedAt: Long,
) )
class QueueKindConverter { class QueueKindConverter {
@@ -24,13 +24,6 @@ class ArtworkSeedRepository(
cacheKey: String, cacheKey: String,
seeds: Pair<Int, Int?>, seeds: Pair<Int, Int?>,
) { ) {
val dao = db.artworkSeedDao() db.artworkSeedDao().upsert(ArtworkSeed(cacheKey, seeds.first, seeds.second))
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
} }
} }