mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-22 19:45: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 totalArticleViews = (await getViews()).views
|
||||||
const topArtist = await getTopArtist()
|
const topArtist = await getTopArtist()
|
||||||
const {genre} = await getTopGenre()
|
const {genre} = await getTopGenre()
|
||||||
const {minutesListened, streams} = await getStats()
|
const {hoursListened, minutesListened, streams} = await getStats()
|
||||||
|
|
||||||
const metrics: Metric[] = [
|
const metrics: Metric[] = [
|
||||||
{
|
{
|
||||||
@ -25,6 +25,12 @@ export async function getDashboardData() {
|
|||||||
group: "Spotify",
|
group: "Spotify",
|
||||||
href: "https://open.spotify.com/?"
|
href: "https://open.spotify.com/?"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "Hours listened",
|
||||||
|
value: +hoursListened,
|
||||||
|
group: "Spotify",
|
||||||
|
href: "https://open.spotify.com/?"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "Minutes listened",
|
title: "Minutes listened",
|
||||||
value: +minutesListened,
|
value: +minutesListened,
|
||||||
|
@ -18,10 +18,13 @@ 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 {durationMs} = response.items
|
||||||
|
const hoursListened = (durationMs / 3_600_000).toFixed(0)
|
||||||
|
const minutesListened = (durationMs / 60_000).toFixed(0)
|
||||||
const streams = response.items.count
|
const streams = response.items.count
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
hoursListened,
|
||||||
minutesListened,
|
minutesListened,
|
||||||
streams
|
streams
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user