Hitlisten: Track Top-40 (since 2007) and Album Top-40 (since 2001) beside the Airplay Top-20, with weeks at #1 and Spotify ids; one hitlisten_charts table (hitlisten_airplay stays as a view)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 01:40:38 +00:00
co-authored by Claude Opus 5.5
parent 347df0d82d
commit 6272fbd75d
4 changed files with 110 additions and 66 deletions
+8 -6
View File
@@ -110,8 +110,8 @@ fn collect(db: &db::Db, args: &[String], db_path: &str) -> Result<()> {
step("new music friday history (superfridaychart)", r.map(|n| format!("{n} ISRCs looked up")), &mut log);
}
if wants("hitlisten") {
let r = hitlisten::collect(db, &http, if backfill { usize::MAX } else { 60 }, &mut log);
step("hitlisten airplay chart", r.map(|n| format!("{n} weeks fetched")), &mut log);
let r = hitlisten::collect(db, &http, arg(args, "--limit").and_then(|l| l.parse().ok()).unwrap_or(if backfill { usize::MAX } else { 60 }), &mut log);
step("hitlisten charts (airplay, track, album)", r.map(|n| format!("{n} weeks fetched")), &mut log);
}
db.conn.execute(
"UPDATE runs SET finished_at = ?1, new_plays = ?2, errors = ?3, log = ?4 WHERE id = ?5",
@@ -138,10 +138,12 @@ fn stats(db: &db::Db) -> Result<()> {
let pdfs: i64 = db.conn.query_row("SELECT count(*) FROM dr_rotation_pdfs", [], |r| r.get(0))?;
println!("DR artist history: {artists} artists, {weeks} artist-week-channel rows; rotation PDFs: {pdfs}");
hitlisten::create_tables(db)?;
let (n, first, last): (i64, Option<String>, Option<String>) = db.conn.query_row(
"SELECT count(DISTINCT year * 100 + week), min(printf('%d-W%02d', year, week)), max(printf('%d-W%02d', year, week)) FROM hitlisten_airplay",
[], |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?)))?;
println!("Hitlisten airplay chart: {n} weeks ({} to {})", first.unwrap_or_default(), last.unwrap_or_default());
for &(chart, _) in hitlisten::CHARTS {
let (n, first, last): (i64, Option<String>, Option<String>) = db.conn.query_row(
"SELECT count(DISTINCT year * 100 + week), min(printf('%d-W%02d', year, week)), max(printf('%d-W%02d', year, week)) FROM hitlisten_charts WHERE chart = ?1",
[chart], |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?)))?;
println!("Hitlisten {chart}: {n} weeks ({} to {})", first.unwrap_or_default(), last.unwrap_or_default());
}
deezer::create_tables(db)?;
let (searched, matched, tracks, albums, labels): (i64, i64, i64, i64, i64) = db.conn.query_row(
"SELECT (SELECT count(*) FROM deezer_searches), (SELECT count(*) FROM deezer_searches WHERE best_track_id IS NOT NULL),