diff options
Diffstat (limited to 'pkgs/by-name/mp/mpdpopm/src/dj/algorithms.rs')
| -rw-r--r-- | pkgs/by-name/mp/mpdpopm/src/dj/algorithms.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/pkgs/by-name/mp/mpdpopm/src/dj/algorithms.rs b/pkgs/by-name/mp/mpdpopm/src/dj/algorithms.rs index 3587df93..0004fd17 100644 --- a/pkgs/by-name/mp/mpdpopm/src/dj/algorithms.rs +++ b/pkgs/by-name/mp/mpdpopm/src/dj/algorithms.rs @@ -4,7 +4,7 @@ use std::{ }; use anyhow::{Context, Result}; -use rand::{RngExt, distr}; +use rand::{RngExt, distr, seq::SliceRandom}; use tracing::info; use crate::{clients::Client, storage}; @@ -115,9 +115,13 @@ impl Algorithm for Discovery { // We split the tracks into three thirds, so that we can also force a pick from e.g. // the lower third (the negative ones). - let negative = sorted_tracks.drain(..len).collect::<Vec<_>>(); - let neutral = sorted_tracks.drain(..len).collect::<Vec<_>>(); - let positive = sorted_tracks; + let mut negative = sorted_tracks.drain(..len).collect::<Vec<_>>(); + let mut neutral = sorted_tracks.drain(..len).collect::<Vec<_>>(); + let mut positive = sorted_tracks; + + negative.shuffle(&mut rng); + neutral.shuffle(&mut rng); + positive.shuffle(&mut rng); assert_eq!(negative.len(), neutral.len()); |
