diff --git a/packages/tourmaline/src/lib/client/load-profile.ts b/packages/tourmaline/src/lib/client/load-profile.ts index 81453b3..9747012 100644 --- a/packages/tourmaline/src/lib/client/load-profile.ts +++ b/packages/tourmaline/src/lib/client/load-profile.ts @@ -159,6 +159,9 @@ export function computeProfile( albumMilestones: data.albumMilestones, longestNotListenedGap: data.longestNotListenedGap, recommendations: buildRecommendations(data.topArtists, data.allArtists, artistInfos), + monthlyArtistPlays: [...data.monthlyArtistPlays.entries()] + .sort(([a], [b]) => a.localeCompare(b)) + .map(([month, plays]) => [month, [...plays.entries()]]), }; const sessions = deriveSessions(filtered); diff --git a/packages/tourmaline/src/lib/types.ts b/packages/tourmaline/src/lib/types.ts index dd4cf32..90d7c46 100644 --- a/packages/tourmaline/src/lib/types.ts +++ b/packages/tourmaline/src/lib/types.ts @@ -137,6 +137,12 @@ export interface ListenerProfile { albumMilestones: Milestone[]; longestNotListenedGap: Gap | null; recommendations: Recommendation[]; + /** + * Chronologically ordered per-month artist play counts, serialized as + * tuples (Maps don't survive structured cloning the way we need for + * $state). Used by the bar-chart-race visualization. + */ + monthlyArtistPlays: Array<[month: string, plays: Array<[artist: string, count: number]>]>; } export interface UnusualMonth {