Skip to content

Open-source status page, incident response and uptime monitoring

🐛 cache tb (#769)

Thibault Le Ouay032db196147c
diff --git a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx
index 98047a553..da5351753 100644
--- a/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx
+++ b/apps/web/src/app/app/[workspaceSlug]/(dashboard)/monitors/(overview)/page.tsx
@@ -40,13 +40,19 @@ export default async function MonitorPage() {
// use Suspense and Client call instead?
const monitorsWithData = await Promise.all(
monitors.map(async (monitor) => {
- const metrics = await tb.endpointMetrics("1d")({
- monitorId: String(monitor.id),
- });
+ const metrics = await tb.endpointMetrics("1d")(
+ {
+ monitorId: String(monitor.id),
+ },
+ { revalidate: 0 },
+ );
- const data = await tb.endpointStatusPeriod("7d")({
- monitorId: String(monitor.id),
- });
+ const data = await tb.endpointStatusPeriod("7d")(
+ {
+ monitorId: String(monitor.id),
+ },
+ { revalidate: 0 },
+ );
const [current] = metrics?.sort((a, b) =>
(a.lastTimestamp || 0) - (b.lastTimestamp || 0) < 0 ? 1 : -1,
diff --git a/packages/tinybird/src/os-client.ts b/packages/tinybird/src/os-client.ts
index bdce373a8..9b898e549 100644
--- a/packages/tinybird/src/os-client.ts
+++ b/packages/tinybird/src/os-client.ts
@@ -100,7 +100,10 @@ export class OSTinybird {
endpointMetrics(period: "1h" | "1d" | "3d" | "7d" | "14d") {
const parameters = z.object({ monitorId: z.string() });
- return async (props: z.infer<typeof parameters>) => {
+ return async (
+ props: z.infer<typeof parameters>,
+ opts?: { revalidate: number | undefined }, // RETHINK: not the best way to handle it
+ ) => {
try {
const res = await this.tb.buildPipe({
pipe: `__ttl_${period}_metrics_get__${VERSION}`,
@@ -115,7 +118,7 @@ export class OSTinybird {
.merge(latencySchema),
opts: {
next: {
- revalidate: DEFAULT_CACHE,
+ revalidate: opts?.revalidate || DEFAULT_CACHE,
},
},
})(props);