Synthetic lists: top-N rule (N = typical DR list size), 4-week blocks (weekly samples are noise); long-history features (archive presence 2012-21, DR lists before t); NMF analysis on full artist histories
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+31
-1
@@ -75,6 +75,10 @@ pub struct Panel {
|
||||
pub list_tau: Option<[u32; C]>,
|
||||
/// Release dates per artist (Deezer discography: singles, EPs, albums), sorted; None = not looked up / not found.
|
||||
pub releases: Vec<Option<Vec<NaiveDate>>>,
|
||||
/// Long history: the artist's plays per 100 archived hours on DR (Wayback, 2012–2021), and the
|
||||
/// dates of DR's real rotation lists (2023–) that had the artist on any channel.
|
||||
pub archive_rate: Vec<f64>,
|
||||
pub listed_on: Vec<Vec<NaiveDate>>,
|
||||
}
|
||||
|
||||
impl Panel {
|
||||
@@ -139,7 +143,8 @@ impl Panel {
|
||||
let chart = chart_states(db, &weeks, &names, artists.len())?;
|
||||
let list_tau = super::calibrate::stored(db)?;
|
||||
let releases = load_releases(db, &id_of, artists.len())?;
|
||||
Ok(Panel { weeks, artists, y, chart, list_tau, releases })
|
||||
let (archive_rate, listed_on) = load_long_history(db, &id_of, &names, artists.len())?;
|
||||
Ok(Panel { weeks, artists, y, chart, list_tau, releases, archive_rate, listed_on })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,3 +247,28 @@ fn load_releases(db: &Db, id_of: &HashMap<String, usize>, n: usize) -> Result<Ve
|
||||
for v in out.iter_mut().flatten() { v.sort(); v.dedup(); }
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
fn load_long_history(db: &Db, id_of: &HashMap<String, usize>, names: &HashMap<String, Vec<usize>>, n: usize) -> Result<(Vec<f64>, Vec<Vec<NaiveDate>>)> {
|
||||
let mut rate = vec![0.0; n];
|
||||
let has = |t: &str| -> Result<bool> { Ok(db.conn.query_row("SELECT count(*) FROM sqlite_master WHERE name = ?1", [t], |r| r.get::<_, i64>(0))? > 0) };
|
||||
if has("archive_plays")? {
|
||||
let hours: f64 = db.conn.query_row("SELECT count(DISTINCT station || substr(played_at, 1, 13)) FROM archive_plays", [], |r| r.get(0))?;
|
||||
let mut st = db.conn.prepare("SELECT artist_ids FROM archive_plays WHERE artist_ids != ''")?;
|
||||
let rows = st.query_map([], |r| r.get::<_, String>(0))?;
|
||||
for r in rows {
|
||||
for id in r?.split(',') { if let Some(&a) = id_of.get(id) { rate[a] += 1.0; } }
|
||||
}
|
||||
if hours > 0.0 { for v in rate.iter_mut() { *v *= 100.0 / hours; } }
|
||||
}
|
||||
let mut listed: Vec<Vec<NaiveDate>> = vec![Vec::new(); n];
|
||||
if has("rotation_lists")? {
|
||||
for r in db.conn.prepare("SELECT DISTINCT list_date, artist FROM rotation_lists")?.query_map([], |r| Ok((r.get::<_, String>(0)?, r.get::<_, String>(1)?)))? {
|
||||
let (d, artist) = r?;
|
||||
let Ok(d) = NaiveDate::parse_from_str(&d, "%Y-%m-%d") else { continue };
|
||||
let list_artist = artist.replace(" [+] ", ", ");
|
||||
for a in chart_artists(&list_artist, names) { listed[a].push(d); }
|
||||
}
|
||||
}
|
||||
for v in listed.iter_mut() { v.sort(); v.dedup(); }
|
||||
Ok((rate, listed))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user