feat: interest over time graph (#127)

* api

* ui

* test

* add margin to prevent clipping
This commit is contained in:
Gabe Farrell 2026-01-12 16:20:31 -05:00 committed by GitHub
parent e45099c71a
commit 231eb1b0fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 1097 additions and 4 deletions

View file

@ -23,6 +23,12 @@ interface timeframe {
to?: number;
period?: string;
}
interface getInterestArgs {
buckets: number;
artist_id: number;
album_id: number;
track_id: number;
}
async function handleJson<T>(r: Response): Promise<T> {
if (!r.ok) {
@ -79,6 +85,13 @@ async function getActivity(
return handleJson<ListenActivityItem[]>(r);
}
async function getInterest(args: getInterestArgs): Promise<InterestBucket[]> {
const r = await fetch(
`/apis/web/v1/interest?buckets=${args.buckets}&album_id=${args.album_id}&artist_id=${args.artist_id}&track_id=${args.track_id}`
);
return handleJson<InterestBucket[]>(r);
}
async function getStats(period: string): Promise<Stats> {
const r = await fetch(`/apis/web/v1/stats?period=${period}`);
@ -315,6 +328,7 @@ export {
getTopAlbums,
getTopArtists,
getActivity,
getInterest,
getStats,
search,
replaceImage,
@ -397,6 +411,11 @@ type ListenActivityItem = {
start_time: Date;
listens: number;
};
type InterestBucket = {
bucket_start: Date;
bucket_end: Date;
listen_count: number;
};
type SimpleArtists = {
name: string;
id: number;
@ -454,6 +473,7 @@ type RewindStats = {
export type {
getItemsArgs,
getActivityArgs,
getInterestArgs,
Track,
Artist,
Album,
@ -461,6 +481,7 @@ export type {
SearchResponse,
PaginatedResponse,
ListenActivityItem,
InterestBucket,
User,
Alias,
ApiKey,