mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-22 13:55:40 +00:00
Added spotify metric to dashboard
This commit is contained in:
parent
576c071a46
commit
f38f432bad
@ -16,7 +16,7 @@ export async function getDashboardData() {
|
||||
const totalArticleViews = (await getViews()).views
|
||||
const topArtist = await getTopArtist()
|
||||
const {genre} = await getTopGenre()
|
||||
const {minutesListened, streams} = await getStats()
|
||||
const {hoursListened, minutesListened, streams} = await getStats()
|
||||
|
||||
const metrics: Metric[] = [
|
||||
{
|
||||
@ -25,6 +25,12 @@ export async function getDashboardData() {
|
||||
group: "Spotify",
|
||||
href: "https://open.spotify.com/?"
|
||||
},
|
||||
{
|
||||
title: "Hours listened",
|
||||
value: +hoursListened,
|
||||
group: "Spotify",
|
||||
href: "https://open.spotify.com/?"
|
||||
},
|
||||
{
|
||||
title: "Minutes listened",
|
||||
value: +minutesListened,
|
||||
|
@ -18,10 +18,13 @@ export const getStats = async () => {
|
||||
}
|
||||
}).then(r => r.json()) as StatsFmResponse
|
||||
|
||||
const minutesListened = ((response.items.durationMs / 1000) / 60).toFixed(0)
|
||||
const {durationMs} = response.items
|
||||
const hoursListened = (durationMs / 3_600_000).toFixed(0)
|
||||
const minutesListened = (durationMs / 60_000).toFixed(0)
|
||||
const streams = response.items.count
|
||||
|
||||
return {
|
||||
hoursListened,
|
||||
minutesListened,
|
||||
streams
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user