Skip to content

Commit

Permalink
stats
Browse files Browse the repository at this point in the history
  • Loading branch information
dietrichmax committed Jan 25, 2024
1 parent 46e905f commit 1baca27
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions pages/stats.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from "react"
import Layout from "@/components/layout/layout"
import config from "@/src/data/internal/SiteConfig"
import styled from "styled-components"
Expand All @@ -9,6 +10,7 @@ import { Button } from "@/styles/templates/button"
import { Client } from "pg"
import {
getMatomoActions,
getMatomoLiveCounter,
getMatomoPageViews,
getMatomoSumVisitDuration,
getMatomoVisitsSummary,
Expand All @@ -32,7 +34,9 @@ import { getGitHubStats } from "@/src/data/external/github"
import PageTitle from "@/components/title/page-title"
import codeStats from "@/src/data/internal/count_total.json"
import SubTitle from "@/components/title/sub-title"
import { useEffect, useState } from "react"
//import { formatDistance } from 'date-fns'
//import { getAllExtensions } from "showdown"
//import Tooltip from "@/components/tooltip/tooltip"

const Container = styled.div`
max-width: var(--width-container);
Expand Down Expand Up @@ -326,27 +330,28 @@ export default function Dashboard({
visitsSummary,
photosCount,
activities,
liveViews,
topPosts,
consentCount,
biggestTrafficSource,
thanks,
commentsCount,
}) {
const [liveViews, setLiveViews] = useState(0)
const router = useRouter()

const { forkCount } = githubStats.user.repository
const stars = githubStats.user.repository.stargazers.totalCount
const githubUrl = "https://github.com/dietrichmax"
const forkUrl = `${githubStats.user.repository.url}/fork`
const starUrl = githubStats.user.repository.url
const lastModified = githubStats.user.repository.pushedAt

const webmentionsCount = allWebmentions.length

const linesOfCode = codeStats.SUM.code

const α = 0.2
const B = 10000
const α = 0.9
const B = 1000
let pageViews = []
let normalisedViews = []
let recentViews = 0
Expand Down Expand Up @@ -387,6 +392,7 @@ export default function Dashboard({
let maxDistance = []
let maxElevationGain = []
let totalElevationGain = 0
let greatestElevationGain = []
let jumpCount = 0

activities.map((item) => {
Expand All @@ -407,15 +413,6 @@ export default function Dashboard({
? consentCount.find((element) => element.label === "consent - false")
: 0

async function getMatomoLiveCounter() {
const res = await fetch("/api/stats")
const stats = await res.json()
}

useEffect(() => {
getMatomoLiveCounter()
}, [])

return (
<>
<Layout>
Expand All @@ -433,7 +430,7 @@ export default function Dashboard({
<StatsGrid>
<Title>Web Analytics</Title>
<StatsLargeGrid>
<GridStats>{liveViews}</GridStats>
<GridStats>{liveViews[0].visitors}</GridStats>
<GridStatsDescription>
Visitors in the last 5 minutes
</GridStatsDescription>
Expand Down Expand Up @@ -872,6 +869,7 @@ export async function getStaticProps() {
const allWebmentions = (await fetchWebmentions()) || []
const visitsSummary = (await getMatomoVisitsSummary()) || []
const activities = (await getAllActivities()) || []
const liveViews = (await getMatomoLiveCounter()) || []
const topPosts = (await getMatomoTopPageUrls()) || []
const consentCount = (await getMatomoConsent()) || []
const biggestTrafficSource = (await getBiggestTrafficSource()) || []
Expand Down Expand Up @@ -902,6 +900,7 @@ export async function getStaticProps() {
visitsSummary,
photosCount,
activities,
liveViews,
topPosts,
consentCount,
biggestTrafficSource,
Expand Down

0 comments on commit 1baca27

Please sign in to comment.