From a8a47ed94dda87c3fe4cdecc0acb9a31f53f00a5 Mon Sep 17 00:00:00 2001 From: tommy Date: Tue, 29 Oct 2024 21:56:00 -0400 Subject: [PATCH] fix: retrieve date as string Apparently prisma can automatically cast dates to UTC, formatting the date to a string in the query can prevent this. --- src/server/model/monitor/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/model/monitor/index.ts b/src/server/model/monitor/index.ts index 5abf56e..5211827 100644 --- a/src/server/model/monitor/index.ts +++ b/src/server/model/monitor/index.ts @@ -82,7 +82,7 @@ export async function getMonitorSummaryWithDay( const list = await prisma.$queryRaw` SELECT - DATE("createdAt") AS day, + TO_CHAR(DATE("createdAt"), 'YYYY-MM-DD') AS day, COUNT(1) AS total_count, SUM(CASE WHEN "value" >= 0 THEN 1 ELSE 0 END) AS up_count, (SUM(CASE WHEN "value" >= 0 THEN 1 ELSE 0 END) * 100.0 / COUNT(1)) AS up_rate