Archived
Summarise this report on every report (2.0.1)
The eight reports that list people get the AI summary too, sent as anonymised totals built on the screen (aiReportData.ts): no names, contact details, notes or comments; consent and medical only as counts. The server refuses personal columns on those reports and logs each summary in the access log (ai_report; sensitive for consent and medical). Roadmap §18: 2.0.1, then crosscode.co.za, then 2.1.0 (AI helpers on the Consent log and Access log). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import { REPORTS, type ReportKey } from "./ReportCatalog";
|
||||
import ReportsShell from "./ReportsShell";
|
||||
import ReportViewerModal, { ReportActionButton } from "./ReportViewerModal";
|
||||
import { AiReportSummary } from "./AiReportSummary";
|
||||
import { aiReportData, type AiReportData } from "./aiReportData";
|
||||
import { AiFeedbackSummary } from "./AiFeedbackSummary";
|
||||
import { StatTile, StatTileRow } from "./StatTile";
|
||||
import { HorizontalBarChart } from "./charts/HorizontalBarChart";
|
||||
@@ -1387,6 +1388,30 @@ export default function ReportsV2({ backHref }: { backHref?: string } = {}) {
|
||||
return null;
|
||||
};
|
||||
|
||||
/** What "Summarise this report" sends: the figures, never the people (see aiReportData). */
|
||||
const buildAiPayload = (): AiReportData | null => {
|
||||
if (report === "attendees") {
|
||||
// On screen a list of names per option: the AI gets how many people and tickets per option and status.
|
||||
const rows: (string | number)[][] = [];
|
||||
for (const opt of attendeesLayer.options) {
|
||||
const byStatus = new Map<string, { people: number; qty: number }>();
|
||||
for (const u of opt.users) {
|
||||
const g = byStatus.get(u.status) ?? { people: 0, qty: 0 };
|
||||
g.people += 1;
|
||||
g.qty += u.qty || 0;
|
||||
byStatus.set(u.status, g);
|
||||
}
|
||||
for (const [status, g] of byStatus) rows.push([opt.optionName, status, g.people, g.qty]);
|
||||
}
|
||||
return {
|
||||
title: `Attendees: ${attendeesLayer.eventTitle}`, subtitle: `Generated ${new Date().toLocaleString()}${attIncludeCancelled ? " (cancelled included)" : ""}`,
|
||||
stats: [{ label: "People", value: new Set(attendeesLayer.options.flatMap(o => o.users.map(u => u.name))).size }],
|
||||
columns: ["Option", "Status", "People", "Tickets"], rows,
|
||||
};
|
||||
}
|
||||
return aiReportData(report, buildReportPayload());
|
||||
};
|
||||
|
||||
const doExportExcel = async () => {
|
||||
if (!token) { alert('Please login to export Excel'); return; }
|
||||
try {
|
||||
@@ -1568,7 +1593,7 @@ export default function ReportsV2({ backHref }: { backHref?: string } = {}) {
|
||||
{!ready && <div className="text-sm text-gray-400">Loading…</div>}
|
||||
{ready && (
|
||||
<>
|
||||
<AiReportSummary key={report} reportKey={report} getPayload={buildReportPayload} />
|
||||
<AiReportSummary key={report} reportKey={report} getPayload={buildAiPayload} />
|
||||
{report === "payments" && (
|
||||
<div>
|
||||
{paymentRows.length === 0 ? (
|
||||
|
||||
Reference in New Issue
Block a user