mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
drop the artwork seed expiry
This commit is contained in:
@@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user