possible popularity fix for playlists
CI / check (push) Successful in 1m22s
CI / docker (push) Has been cancelled

This commit is contained in:
Connor Johnstone
2026-04-01 23:13:16 -04:00
parent 31c9785ed2
commit cab680ad5d
+11 -5
View File
@@ -197,6 +197,9 @@ pub fn score_tracks(
}
}
// Apply to ALL tracks: popular ones get boosted, unknown ones get reduced.
// Factor range: unknown tracks get `1 - gp_strength` (minimum 0.01),
// top global track gets 1.0 + gp_strength (up to 2.0 at max setting).
for t in &mut result {
let playcount = t
.title
@@ -204,14 +207,17 @@ pub fn score_tracks(
.and_then(|title| global_playcounts.get(&title.to_lowercase()).copied())
.unwrap_or(0);
if playcount > 0 {
let global_pop = (playcount as f64 / global_max as f64).powf(gp_exponent);
// lerp(1.0, global_pop, gp_strength)
let factor = 1.0 + gp_strength * (global_pop - 1.0);
let global_pop = if playcount > 0 {
(playcount as f64 / global_max as f64).powf(gp_exponent)
} else {
0.0
};
// Map global_pop [0, 1] to a factor centered around 1.0:
// global_pop=0 → 1.0 - gp_strength, global_pop=1 → 1.0 + gp_strength
let factor = (1.0 + gp_strength * (2.0 * global_pop - 1.0)).max(0.01);
t.score *= factor;
}
}
}
result
}