mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-22 19:25:41 +00:00
Added spotify metric to dashboard
This commit is contained in:
parent
914493f214
commit
64239feff0
@ -16,9 +16,15 @@ export async function getDashboardData() {
|
|||||||
const totalArticleViews = (await getViews()).views
|
const totalArticleViews = (await getViews()).views
|
||||||
const topArtist = await getTopArtist()
|
const topArtist = await getTopArtist()
|
||||||
const {genre} = await getTopGenre()
|
const {genre} = await getTopGenre()
|
||||||
const {minutesListened} = await getStats()
|
const {minutesListened, streams} = await getStats()
|
||||||
|
|
||||||
const metrics: Metric[] = [
|
const metrics: Metric[] = [
|
||||||
|
{
|
||||||
|
title: "Streams",
|
||||||
|
value: +streams,
|
||||||
|
group: "Spotify",
|
||||||
|
href: "https://open.spotify.com/?"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "Minutes listened",
|
title: "Minutes listened",
|
||||||
value: +minutesListened,
|
value: +minutesListened,
|
||||||
|
@ -6,6 +6,7 @@ const STATSFM_LIFETIME_STATS = `https://beta-api.stats.fm/api/v1/users/${STATSFM
|
|||||||
type StatsFmResponse = {
|
type StatsFmResponse = {
|
||||||
items: {
|
items: {
|
||||||
durationMs: number
|
durationMs: number
|
||||||
|
count: number
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,8 +19,10 @@ export const getStats = async () => {
|
|||||||
}).then(r => r.json()) as StatsFmResponse
|
}).then(r => r.json()) as StatsFmResponse
|
||||||
|
|
||||||
const minutesListened = ((response.items.durationMs / 1000) / 60).toFixed(0)
|
const minutesListened = ((response.items.durationMs / 1000) / 60).toFixed(0)
|
||||||
|
const streams = response.items.count
|
||||||
|
|
||||||
return {
|
return {
|
||||||
minutesListened
|
minutesListened,
|
||||||
|
streams
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user