From 2e904c21ee3e46b7d4d2493e19a22aab10637d52 Mon Sep 17 00:00:00 2001 From: Thibault Le Ouay Date: Wed, 18 Dec 2024 21:21:44 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20save=20some=20bandwith=20and=20m?= =?UTF-8?q?emory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/checker/handlers/checker.go | 5 +++++ apps/server/src/v1/monitors/trigger/post.ts | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/checker/handlers/checker.go b/apps/checker/handlers/checker.go index c0805081b1..d4beb153a3 100644 --- a/apps/checker/handlers/checker.go +++ b/apps/checker/handlers/checker.go @@ -311,6 +311,11 @@ func (h Handler) HTTPCheckerHandler(c *gin.Context) { returnData := c.Query("data") if returnData == "true" { + + if len(result.Body) > 1024 { + result.Body = result.Body[:1000] + } + c.JSON(http.StatusOK, result) return diff --git a/apps/server/src/v1/monitors/trigger/post.ts b/apps/server/src/v1/monitors/trigger/post.ts index f67351e40c..490c8de9d8 100644 --- a/apps/server/src/v1/monitors/trigger/post.ts +++ b/apps/server/src/v1/monitors/trigger/post.ts @@ -54,8 +54,8 @@ export function registerTriggerMonitor(api: typeof monitorsApi) { .where( and( eq(monitorRun.workspaceId, Number(workspaceId)), - gte(monitorRun.createdAt, new Date(lastMonth)), - ), + gte(monitorRun.createdAt, new Date(lastMonth)) + ) ) .all() )[0].count; @@ -73,8 +73,8 @@ export function registerTriggerMonitor(api: typeof monitorsApi) { and( eq(monitor.id, Number(id)), eq(monitor.workspaceId, Number(workspaceId)), - isNull(monitor.deletedAt), - ), + isNull(monitor.deletedAt) + ) ) .get(); @@ -186,9 +186,9 @@ export function registerTriggerMonitor(api: typeof monitorsApi) { function generateUrl({ row }: { row: z.infer }) { switch (row.jobType) { case "http": - return `https://openstatus-checker.fly.dev/checker/http?monitor_id=${row.id}&trigger=api&data=true`; + return `https://openstatus-checker.fly.dev/checker/http?monitor_id=${row.id}&trigger=api&data=false`; case "tcp": - return `https://openstatus-checker.fly.dev/checker/tcp?monitor_id=${row.id}&trigger=api&data=true`; + return `https://openstatus-checker.fly.dev/checker/tcp?monitor_id=${row.id}&trigger=api&data=false`; default: throw new Error("Invalid jobType"); }