Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.0 kB ยท 35 lines
TypeScript
at incident-api
123456789101112131415161718192021222324252627282930313233343536import type { StatusReportImpact } from "@openstatus/ui/components/blocks/status.types";
type ReportWithImpactRows<U> = { statusReportsToPageComponents: { pageComponent: { id: number; name: string }; }[]; statusReportUpdates: U[];};
/** * Maps a report's update impact rows to the `impactChanges` shape consumed by * the timeline blocks, resolving component names from the report associations. */export function updatesWithImpactChanges< U extends { statusReportUpdateToPageComponents: { pageComponentId: number; impact: StatusReportImpact; }[]; },>(report: ReportWithImpactRows<U>) { const nameById = new Map( report.statusReportsToPageComponents.map((a) => [ a.pageComponent.id, a.pageComponent.name, ]), ); return report.statusReportUpdates.map((update) => ({ ...update, impactChanges: update.statusReportUpdateToPageComponents.map((ci) => ({ name: nameById.get(ci.pageComponentId) ?? `#${ci.pageComponentId}`, impact: ci.impact, })), }));}