Openstatus www.openstatus.dev

feat: 30 days lookback (#1104)

* feat: 30 days lookback

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>

authored by

Maximilian Kaske
autofix-ci[bot]
and committed by
GitHub
a95f63a6 42e6ad12

+19 -1
+8
apps/web/src/app/status-page/[domain]/page.tsx
··· 9 9 import { api } from "@/trpc/server"; 10 10 import { Separator } from "@openstatus/ui"; 11 11 12 + /** 13 + * Right now, we do not allow workspaces to have a custom lookback period. 14 + * If we decide to allow this in the future, we should move this to the database. 15 + */ 16 + const WORKSPACES = 17 + process.env.WORKSPACES_LOOKBACK_30?.split(",").map(Number) || []; 18 + 12 19 type Props = { 13 20 params: { domain: string }; 14 21 searchParams: { [key: string]: string | string[] | undefined }; ··· 49 56 incidents={page.incidents} 50 57 maintenances={page.maintenances} 51 58 showMonitorValues={!!page.showMonitorValues} 59 + totalDays={WORKSPACES.includes(page.workspaceId) ? 30 : 45} 52 60 /> 53 61 ) : ( 54 62 <EmptyState
+3
apps/web/src/components/status-page/monitor-list.tsx
··· 15 15 incidents, 16 16 maintenances, 17 17 showMonitorValues, 18 + totalDays, 18 19 }: { 19 20 monitors: PublicMonitor[]; 20 21 statusReports: z.infer<typeof selectPublicStatusReportSchemaWithRelation>[]; 21 22 incidents: Incident[]; 22 23 maintenances: Maintenance[]; 23 24 showMonitorValues?: boolean; 25 + totalDays?: number; 24 26 }) => { 25 27 return ( 26 28 <div className="grid gap-4"> ··· 44 46 incidents={monitorIncidents} 45 47 maintenances={monitorMaintenances} 46 48 showValues={showMonitorValues} 49 + totalDays={totalDays} 47 50 /> 48 51 ); 49 52 })}
+3
apps/web/src/components/status-page/monitor.tsx
··· 16 16 incidents, 17 17 maintenances, 18 18 showValues, 19 + totalDays, 19 20 }: { 20 21 monitor: PublicMonitor; 21 22 statusReports: z.infer<typeof selectPublicStatusReportSchemaWithRelation>[]; 22 23 incidents: Incident[]; 23 24 maintenances: Maintenance[]; 24 25 showValues?: boolean; 26 + totalDays?: number; 25 27 }) => { 26 28 const res = await prepareStatusByPeriod( 27 29 "45d", 28 30 monitor.jobType as "http" | "tcp", 29 31 ).getData({ 30 32 monitorId: String(monitor.id), 33 + days: totalDays, 31 34 }); 32 35 33 36 // TODO: we could handle the `statusReports` here instead of passing it down to the tracker
+1 -1
packages/db/src/schema/shared.ts
··· 73 73 .transform((val) => val ?? "free"), 74 74 }) 75 75 .omit({ 76 - workspaceId: true, 76 + // workspaceId: true, 77 77 id: true, 78 78 }); 79 79
+1
packages/tinybird/pipes/endpoint__http_status_45d.pipe
··· 18 18 TO toStartOfDay( 19 19 date_sub(DAY, 45, now()) 20 20 ) STEP INTERVAL -1 DAY 21 + LIMIT {{ Int16(days, 45) }} 21 22 22 23
+1
packages/tinybird/pipes/endpoint__tcp_status_45d.pipe
··· 18 18 TO toStartOfDay( 19 19 date_sub(DAY, 45, now()) 20 20 ) STEP INTERVAL -1 DAY 21 + LIMIT {{ Int16(days, 45) }} 21 22 22 23
+2
packages/tinybird/src/client.ts
··· 304 304 pipe: "endpoint__http_status_45d__v0", 305 305 parameters: z.object({ 306 306 monitorId: z.string(), 307 + days: z.number().int().max(45).optional(), 307 308 }), 308 309 data: z.object({ 309 310 day: z.string().transform((val) => { ··· 644 645 pipe: "endpoint__tcp_status_45d__v0", 645 646 parameters: z.object({ 646 647 monitorId: z.string(), 648 + days: z.number().int().max(45).optional(), 647 649 }), 648 650 data: z.object({ 649 651 day: z.string().transform((val) => {