fix: never replay a client-excluded track in a radio batch
This commit is contained in:
1 parent
ef536d1882
commit
61d8b58223
2 files changed
+16
-2
No files matched your search
@@ -99,8 +99,12 @@ class RadioService(
|
|||||||
// within one batch.
|
// within one batch.
|
||||||
if (picks.size < limit) {
|
if (picks.size < limit) {
|
||||||
val pickedIds = picks.map { it.id }.toSet()
|
val pickedIds = picks.map { it.id }.toSet()
|
||||||
val heardCollection = collection.filter { it.id in skip && it.id !in pickedIds }
|
val heardCollection = collection.filter {
|
||||||
val heardRecommendations = recommendations.filter { it.id in skip && it.id !in pickedIds }
|
it.id in sessionSongs && it.id !in excluded && it.id !in pickedIds
|
||||||
|
}
|
||||||
|
val heardRecommendations = recommendations.filter {
|
||||||
|
it.id in sessionSongs && it.id !in excluded && it.id !in pickedIds
|
||||||
|
}
|
||||||
picks += pickMixed(
|
picks += pickMixed(
|
||||||
collectionScored = score(heardCollection, affinity, recent, heard = true),
|
collectionScored = score(heardCollection, affinity, recent, heard = true),
|
||||||
recommendationScored = score(heardRecommendations, affinity, recent, heard = true),
|
recommendationScored = score(heardRecommendations, affinity, recent, heard = true),
|
||||||
|
|||||||
@@ -224,6 +224,16 @@ class ApiRoutesTest {
|
|||||||
.map { it.jsonObject.string("id") }
|
.map { it.jsonObject.string("id") }
|
||||||
assertEquals(nextIds.size, nextIds.distinct().size)
|
assertEquals(nextIds.size, nextIds.distinct().size)
|
||||||
|
|
||||||
|
// Client-held tracks are never replayed even when the pool is
|
||||||
|
// exhausted and the session would otherwise repeat.
|
||||||
|
val excluded = client.post("/api/v1/sessions/$sessionId/next") {
|
||||||
|
bearer(token)
|
||||||
|
contentType(ContentType.Application.Json)
|
||||||
|
setBody("""{"limit":5,"excludeSongIds":["${seed.ambient1}"]}""")
|
||||||
|
}
|
||||||
|
assertEquals(HttpStatusCode.OK, excluded.status)
|
||||||
|
assertTrue(parse(excluded.bodyAsText())["songs"]!!.jsonArray.isEmpty())
|
||||||
|
|
||||||
val event = client.post("/api/v1/sessions/$sessionId/events") {
|
val event = client.post("/api/v1/sessions/$sessionId/events") {
|
||||||
bearer(token)
|
bearer(token)
|
||||||
contentType(ContentType.Application.Json)
|
contentType(ContentType.Application.Json)
|
||||||
|
|||||||
Reference in new issue
Block a user