feat: rotate recommendations after a few plays
CI / chart (push) Successful in 3s
CI / test (push) Successful in 2m4s
CI / chart-push (push) Successful in 3s
CI / image (push) Failing after 6m21s

- V12 rebuilds mood_recommendations with a rotated state, play_count and
  rotated_at, plus a per-mood recommendation_rotation_plays (default 3)
- count a play when a session reports started; retire the slot at the limit
  and let TopUpService refill it, with discovery only when the pool is empty
- add POST /moods/{id}/recommendations/rotate for the All new action, which
  retires every active slot and forces discovery
- turned a rotated slot's late download completion into REJECTED so it cannot
  reappear as ready
- revive rotated slots after a 30-day cooldown to avoid draining the catalog
- expose playCount and recommendationRotationPlays in the API, chart 0.6.0
This commit is contained in:
TapTap committed 2026-11-22 17:31:28 +00:00
1 parent 44b75c4d4d
commit a3c5da559b
15 files changed
+507 -8

No files matched your search

@@ -38,6 +38,17 @@ class DiscoveryService(
return DiscoveryOutcome(0, skipped = true)
}
// Rotation is a cooldown, not a rejection: tracks retired a while ago
// may be offered again instead of draining the catalog forever.
val revived = MoodRepository.reviveRotated(
mood.id,
mood.source,
now.minus(ROTATION_COOLDOWN_DAYS, ChronoUnit.DAYS),
)
if (revived > 0) {
log.info("Revived {} rotated recommendations for mood {}", revived, mood.name)
}
val catalog = catalogs.forSource(mood.source)
val collection = MoodRepository.songRecords(mood.id)
val artists = artistsByFrequency(collection)
@@ -180,6 +191,7 @@ class DiscoveryService(
const val DISCOVERY_LIMIT = 200
const val RADIO_SEEDS = 2
const val CANDIDATE_POOL = 60
const val ROTATION_COOLDOWN_DAYS = 30L
}
}