mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
feat(api): add endpoint for retrieving growth data for the dashboard
This commit is contained in:
@@ -36,6 +36,11 @@ export type Health = {
|
||||
oldest_event_ts: number | null
|
||||
}
|
||||
|
||||
export type Growth = {
|
||||
daily: { day: string; users: number; requests: number }[]
|
||||
weekly: { week: string; users: number; requests: number }[]
|
||||
}
|
||||
|
||||
async function getJSON<T>(path: string): Promise<T> {
|
||||
const r = await fetch(path, { credentials: 'include' })
|
||||
if (r.status === 401) throw new Error('unauthorized')
|
||||
@@ -49,3 +54,4 @@ export const fetchUsers = (q = '', sort = 'requests') =>
|
||||
getJSON<UserRow[]>(`/api/dev/users?q=${encodeURIComponent(q)}&sort=${sort}`)
|
||||
export const fetchLatency = () => getJSON<LatencyRow[]>('/api/dev/latency')
|
||||
export const fetchHealth = () => getJSON<Health>('/api/dev/health')
|
||||
export const fetchGrowth = () => getJSON<Growth>('/api/dev/growth')
|
||||
|
||||
@@ -5,6 +5,7 @@ import { StatCards } from '../components/StatCards'
|
||||
import { UsersTable } from '../components/UsersTable'
|
||||
import { LatencyChart } from '../components/LatencyChart'
|
||||
import { HealthStrip } from '../components/HealthStrip'
|
||||
import { GrowthChart } from '../components/GrowthChart'
|
||||
|
||||
const REFRESH_MS = 15_000
|
||||
|
||||
@@ -45,6 +46,9 @@ export function DevScreen() {
|
||||
return (
|
||||
<Shell lastRefresh={lastRefresh}>
|
||||
{s ? <StatCards s={s} /> : <div className="text-white/40">loading…</div>}
|
||||
<div className="mt-6">
|
||||
<GrowthChart />
|
||||
</div>
|
||||
<div className="mt-6">
|
||||
<UsersTable />
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user