possible popularity fix for playlists
This commit is contained in:
@@ -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 {
|
for t in &mut result {
|
||||||
let playcount = t
|
let playcount = t
|
||||||
.title
|
.title
|
||||||
@@ -204,14 +207,17 @@ pub fn score_tracks(
|
|||||||
.and_then(|title| global_playcounts.get(&title.to_lowercase()).copied())
|
.and_then(|title| global_playcounts.get(&title.to_lowercase()).copied())
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
|
|
||||||
if playcount > 0 {
|
let global_pop = if playcount > 0 {
|
||||||
let global_pop = (playcount as f64 / global_max as f64).powf(gp_exponent);
|
(playcount as f64 / global_max as f64).powf(gp_exponent)
|
||||||
// lerp(1.0, global_pop, gp_strength)
|
} else {
|
||||||
let factor = 1.0 + gp_strength * (global_pop - 1.0);
|
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;
|
t.score *= factor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user