mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-22 19:45:40 +00:00
Added total views metric to dashboard
This commit is contained in:
parent
9745b2da7b
commit
c719e09c81
@ -1,4 +1,5 @@
|
|||||||
import {GetServerSidePropsContext} from 'next'
|
import {GetServerSidePropsContext} from 'next'
|
||||||
|
import {createServerSupabaseClient} from '@supabase/auth-helpers-nextjs'
|
||||||
import {
|
import {
|
||||||
getTopRepo,
|
getTopRepo,
|
||||||
getTotalFollowers,
|
getTotalFollowers,
|
||||||
@ -12,6 +13,8 @@ import {getStats} from '@/lib/statsfm'
|
|||||||
import {Metric} from '@/types'
|
import {Metric} from '@/types'
|
||||||
|
|
||||||
export async function getDashboardData(context: GetServerSidePropsContext) {
|
export async function getDashboardData(context: GetServerSidePropsContext) {
|
||||||
|
const supabaseClient = createServerSupabaseClient(context)
|
||||||
|
const {data: views} = await supabaseClient.rpc('total_views')
|
||||||
const [totalRepos, totalFollowers] = await Promise.all([
|
const [totalRepos, totalFollowers] = await Promise.all([
|
||||||
getTotalRepos(),
|
getTotalRepos(),
|
||||||
getTotalFollowers()
|
getTotalFollowers()
|
||||||
@ -21,7 +24,7 @@ export async function getDashboardData(context: GetServerSidePropsContext) {
|
|||||||
const totalStars = await getTotalStars(totalRepos)
|
const totalStars = await getTotalStars(totalRepos)
|
||||||
const totalForks = await getTotalForks(totalRepos)
|
const totalForks = await getTotalForks(totalRepos)
|
||||||
const totalArticles = (await getAllArticles()).length
|
const totalArticles = (await getAllArticles()).length
|
||||||
// const totalArticleViews = (await getViews()).views
|
const totalViews = views
|
||||||
const topArtist = await getTopArtist()
|
const topArtist = await getTopArtist()
|
||||||
const {genre} = await getTopGenre()
|
const {genre} = await getTopGenre()
|
||||||
const {hoursListened, minutesListened, streams} = await getStats()
|
const {hoursListened, minutesListened, streams} = await getStats()
|
||||||
@ -90,15 +93,15 @@ export async function getDashboardData(context: GetServerSidePropsContext) {
|
|||||||
{
|
{
|
||||||
title: "Total articles",
|
title: "Total articles",
|
||||||
value: +totalArticles,
|
value: +totalArticles,
|
||||||
group: "Blog",
|
group: "Website",
|
||||||
href: "/writing"
|
href: "/writing"
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// title: "Total article views",
|
title: "Total views",
|
||||||
// value: +totalArticleViews,
|
value: +totalViews,
|
||||||
// group: "Blog",
|
group: "Website",
|
||||||
// href: "/writing"
|
href: "/"
|
||||||
// }
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
// sort metrics into named groups
|
// sort metrics into named groups
|
||||||
|
Loading…
Reference in New Issue
Block a user