Channel affinity (share of the artist's DR plays per station before t, never played there) and genre fit (DR genre x station) in the per-station rows; Best week: any date range up to 12 months

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 13:00:34 +00:00
co-authored by Claude Opus 5.5
parent 6d1f97f5bd
commit bc222d3cd0
5 changed files with 141 additions and 34 deletions
+7 -1
View File
@@ -326,8 +326,14 @@ fn bestweek(st: &State, q: &HashMap<String, String>) -> Result<Reply> {
let nmf = match q.get("nmf").map(String::as_str) { Some("yes") => Some(true), Some("no") => Some(false), _ => None };
let p = &m.panel;
let t0 = p.w() - 1;
// Release weeks between `from` and `to` (default: the next 26), at most 53 weeks, from next week on.
let first = p.weeks[t0] + chrono::Duration::weeks(1);
let date = |k: &str| q.get(k).and_then(|s| chrono::NaiveDate::parse_from_str(s, "%Y-%m-%d").ok());
let wk = |d: chrono::NaiveDate| ((d - first).num_days().div_euclid(7)).max(0) as usize;
let h0 = date("from").map(wk).unwrap_or(0);
let h1 = date("to").map(wk).unwrap_or(h0 + CALENDAR - 1).max(h0).min(h0 + 52);
let groups = [("P3", vec![0usize]), ("P4", (0..C).filter(|&c| crate::model::panel::is_p4(c)).collect()), ("P5", vec![11]), ("P6", vec![12]), ("P8", vec![13])];
let weeks: Vec<Value> = (0..CALENDAR).map(|h| {
let weeks: Vec<Value> = (h0..=h1).map(|h| {
let start = p.weeks[t0] + chrono::Duration::weeks(h as i64 + 1);
let xmas = crate::model::features::christmas(p, t0 + h + 1);
match new_song(m, a, h, win, nmf) {