2026-08-25 21:26:18 +02:00
|
|
|
import type { Metadata } from "next";
|
2026-08-25 07:51:38 +02:00
|
|
|
import { SessionsSummaryCards } from "@/components/stats/SessionsSummaryCards";
|
|
|
|
|
import { DeviceUsageTable } from "@/components/stats/DeviceUsageTable";
|
2026-08-27 21:38:51 +02:00
|
|
|
import { getDeviceCommandCounts, getDeviceUsageStats, getSessionsSummary } from "@/lib/db/queries/stats";
|
2026-08-25 07:51:38 +02:00
|
|
|
|
|
|
|
|
export const dynamic = "force-dynamic";
|
2026-08-25 21:26:18 +02:00
|
|
|
export const metadata: Metadata = { title: "Stats" };
|
2026-08-25 07:51:38 +02:00
|
|
|
|
|
|
|
|
export default async function StatsPage() {
|
2026-08-27 21:38:51 +02:00
|
|
|
const [sessionsSummary, deviceUsage, commandCounts] = await Promise.all([
|
2026-08-25 07:51:38 +02:00
|
|
|
getSessionsSummary(),
|
|
|
|
|
getDeviceUsageStats(),
|
|
|
|
|
getDeviceCommandCounts(),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const commandCountByDevice = new Map(commandCounts.map((c) => [c.deviceId, c.commandCount]));
|
|
|
|
|
const devices = deviceUsage.map((d) => ({ ...d, commandCount: commandCountByDevice.get(d.deviceId) ?? 0 }));
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex flex-col gap-6">
|
|
|
|
|
<div>
|
2026-08-25 16:43:28 +02:00
|
|
|
<h1 className="font-heading text-2xl font-semibold">Stats</h1>
|
2026-08-27 21:38:51 +02:00
|
|
|
<p className="text-sm text-muted-foreground">Usage across sessions and devices.</p>
|
2026-08-25 07:51:38 +02:00
|
|
|
</div>
|
|
|
|
|
|
2026-08-30 20:33:47 +02:00
|
|
|
<SessionsSummaryCards summary={sessionsSummary} />
|
|
|
|
|
<DeviceUsageTable devices={devices} />
|
2026-08-25 07:51:38 +02:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|