diff --git a/admin-ui/app/page.tsx b/admin-ui/app/page.tsx
index 4709fa0..78cdccf 100644
--- a/admin-ui/app/page.tsx
+++ b/admin-ui/app/page.tsx
@@ -3,7 +3,7 @@ import { AppShell } from "@/components/AppShell";
import { DataAlert } from "@/components/DataAlert";
import { KpiCard } from "@/components/KpiCard";
import { computeKpis, fetchIncidentList } from "@/lib/incidents-data";
-import { fetchOperationalStats } from "@/lib/stats-data";
+import { aggregateIncidentKpisFromSummary, fetchOperationalStats } from "@/lib/stats-data";
/** Respect runtime env (e.g. ERROR_REPORTING_UI_DEMO) — avoid stale prerender behind CDN. */
export const dynamic = "force-dynamic";
@@ -35,7 +35,10 @@ export default async function DashboardPage() {
);
}
- const _kpis = computeKpis(_list.incidents);
+ const _kpiFromStats = _stats.ok;
+ const _kpis = _kpiFromStats
+ ? aggregateIncidentKpisFromSummary(_stats.summary)
+ : computeKpis(_list.incidents);
const _sourceHint =
_list.source === "demo" ? (
@@ -48,7 +51,11 @@ export default async function DashboardPage() {
{_sourceHint}
-
+
diff --git a/admin-ui/lib/stats-data.ts b/admin-ui/lib/stats-data.ts
index 5f1f6a6..e5b8eac 100644
--- a/admin-ui/lib/stats-data.ts
+++ b/admin-ui/lib/stats-data.ts
@@ -1,4 +1,5 @@
import { cookies } from "next/headers";
+import type { IncidentState } from "./types";
function _envStr(key: string): string | undefined {
const v = Reflect.get(process.env, key);
@@ -103,6 +104,27 @@ export type OperationalStatsResult =
}
| { ok: false; message: string };
+/** Global incident counts from SQL aggregates — not limited by the incidents list page size. */
+export function aggregateIncidentKpisFromSummary(
+ summary: StatsSummaryPayload,
+): Record {
+ const _acc: Record = {
+ total: 0,
+ open: 0,
+ investigating: 0,
+ resolved: 0,
+ ignored: 0,
+ };
+ for (const _r of summary.byProject) {
+ _acc.total += _r.total;
+ _acc.open += _r.open;
+ _acc.investigating += _r.investigating;
+ _acc.resolved += _r.resolved;
+ _acc.ignored += _r.ignored;
+ }
+ return _acc;
+}
+
export async function fetchOperationalStats(): Promise {
if (!_apiBase()) {
return { ok: false, message: "API não configurada." };