Zum Inhalt

Dashboard

Seite: app/dashboard/page.tsx (177 Zeilen) API: app/api/dashboard/stats/route.ts (78 Zeilen) Pfad: /dashboard

Übersicht

Das Dashboard zeigt Echtzeit-Plattform-Metriken in sechs StatCards und einer Tabelle der letzten Kaufabsichten.

┌──────────────┐  ┌──────────────┐  ┌──────────────┐
│ Total Users  │  │ Revenue 24h  │  │ Failed 24h   │
│    1.234     │  │  5.678 USDT  │  │     12       │
│ +5 today     │  │              │  │ 3 last hour  │
└──────────────┘  └──────────────┘  └──────────────┘
┌──────────────┐  ┌──────────────┐  ┌──────────────┐
│ Vouchers     │  │ Active 1h    │  │Last Settlement│
│   89 Tips    │  │ 3/2/1        │  │ Day 20501    │
│ outstanding  │  │ C/S/E        │  │ committed    │
└──────────────┘  └──────────────┘  └──────────────┘

┌─────────────────────────────────────────────────┐
│ Recent Intents (letzte 20)                      │
│ Time | Buyer | Pool | Tips | Cost | Status      │
└─────────────────────────────────────────────────┘

Metriken

Total Users

SELECT COUNT(*) as total,
       COUNT(*) FILTER (WHERE created_at > now() - interval '24 hours') as today,
       COUNT(*) FILTER (WHERE created_at > now() - interval '7 days') as week
FROM users

Revenue (24h)

SELECT COALESCE(SUM(total_cost::bigint), 0) as today
FROM buy_intents
WHERE status = 'CONFIRMED'
  AND created_at > now() - interval '24 hours'

Anzeige in USDT (Division durch 10^6).

Failed Intents (24h)

SELECT COUNT(*) as today,
       COUNT(*) FILTER (WHERE created_at > now() - interval '1 hour') as last_hour
FROM buy_intents
WHERE status = 'FAILED'
  AND created_at > now() - interval '24 hours'

Outstanding Vouchers

SELECT COALESCE(SUM(amount), 0) as outstanding
FROM extra_bonus_vouchers
WHERE used = false
  AND (expires_at IS NULL OR expires_at > now())

Active Intents (1h)

SELECT
  COUNT(*) FILTER (WHERE status = 'CREATED') as created,
  COUNT(*) FILTER (WHERE status = 'SIGNED') as signed,
  COUNT(*) FILTER (WHERE status = 'EXECUTING') as executing
FROM buy_intents
WHERE created_at > now() - interval '1 hour'

Last Settlement

SELECT day_id, status, created_at
FROM settlement_runs
ORDER BY day_id DESC
LIMIT 1

Recent Intents

SELECT intent_id, buyer, pool_id, tip_count, bonus_tip_count,
       total_cost, status, error_code, created_at
FROM buy_intents
ORDER BY created_at DESC
LIMIT 20

Pool-Mapping

Pool-ID Name
0 Micro
1 Mini
2 Standard
3 Maxi
4 Ultra

Tabellen-Spalten

Spalte Beschreibung
Time Erstellungszeitpunkt
Buyer Wallet-Adresse (gekürzt)
Pool Pool-Name
Tips Tipps-Anzahl (+Bonus hervorgehoben)
Cost Kosten in USDT
Status StatusBadge (farbcodiert)
Error Fehlercode (falls vorhanden)

Alle Queries werden parallel via Promise.all ausgeführt.