mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-11 18:45: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 topArtist = await getTopArtist()
|
||||
const {genre} = await getTopGenre()
|
||||
const {minutesListened} = await getStats()
|
||||
const {minutesListened, streams} = await getStats()
|
||||
|
||||
const metrics: Metric[] = [
|
||||
{
|
||||
title: "Streams",
|
||||
value: +streams,
|
||||
group: "Spotify",
|
||||
href: "https://open.spotify.com/?"
|
||||
},
|
||||
{
|
||||
title: "Minutes listened",
|
||||
value: +minutesListened,
|
||||
|
@ -6,6 +6,7 @@ const STATSFM_LIFETIME_STATS = `https://beta-api.stats.fm/api/v1/users/${STATSFM
|
||||
type StatsFmResponse = {
|
||||
items: {
|
||||
durationMs: number
|
||||
count: number
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,8 +19,10 @@ export const getStats = async () => {
|
||||
}).then(r => r.json()) as StatsFmResponse
|
||||
|
||||
const minutesListened = ((response.items.durationMs / 1000) / 60).toFixed(0)
|
||||
const streams = response.items.count
|
||||
|
||||
return {
|
||||
minutesListened
|
||||
minutesListened,
|
||||
streams
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user