Skip to content

Commit 9d8dd2b

Browse files
unhappychoiceclaude
andcommitted
feat(fetcher): add lastfm_top_artists
First consumer of the shared `lastfm/top.rs` rendering surface: a user's top artists for a rolling window via `user.getTopArtists`. Options: required `user`, optional `period` (default `"7day"`, also `"1month"` / `"3month"` / `"6month"` / `"12month"` / `"overall"`), optional `limit` (1..=50, default 10). Shapes (10): LinkedTextBlock (default) / ImageLinkedList / TextBlock / Text / MarkdownTextBlock / Entries / Ratio (top artist's share of the window total, denominator carrying the sum) / NumberSeries (playcounts as a sparkline) / Bars / Badge. Rank prefers Last.fm's own `@attr.rank` when present, falling back to the 1-indexed position so a malformed response still renders rather than disappearing. Playcounts that don't parse collapse to zero (`parse_count` shared from `common`). Cache key partitions on period + shape so switching `"7day"` to `"1month"` doesn't serve a stale snapshot. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent db5bacc commit 9d8dd2b

2 files changed

Lines changed: 468 additions & 1 deletion

File tree

‎src/fetcher/lastfm/mod.rs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ mod client;
1313
mod common;
1414
mod scrobbles_today;
1515
mod top;
16+
mod top_artists;
1617

1718
use std::sync::Arc;
1819

1920
use crate::fetcher::Fetcher;
2021

2122
pub fn fetchers() -> Vec<Arc<dyn Fetcher>> {
22-
vec![Arc::new(scrobbles_today::LastfmScrobblesToday)]
23+
vec![
24+
Arc::new(scrobbles_today::LastfmScrobblesToday),
25+
Arc::new(top_artists::LastfmTopArtists),
26+
]
2327
}
2428

2529
#[cfg(test)]
@@ -36,5 +40,6 @@ mod tests {
3640
);
3741
}
3842
assert!(names.contains(&"lastfm_scrobbles_today".to_string()));
43+
assert!(names.contains(&"lastfm_top_artists".to_string()));
3944
}
4045
}

0 commit comments

Comments
 (0)