mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-13 09:30:27 -07:00
feat: interest over time graph (#127)
* api * ui * test * add margin to prevent clipping
This commit is contained in:
parent
e45099c71a
commit
231eb1b0fb
16 changed files with 1097 additions and 4 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue