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.
This commit is contained in:
tommy 2024-10-29 21:56:00 -04:00 committed by moonrailgun
parent 272505669e
commit a8a47ed94d

View File

@ -82,7 +82,7 @@ export async function getMonitorSummaryWithDay(
const list = await prisma.$queryRaw<MonitorSummaryItem[]>` const list = await prisma.$queryRaw<MonitorSummaryItem[]>`
SELECT SELECT
DATE("createdAt") AS day, TO_CHAR(DATE("createdAt"), 'YYYY-MM-DD') AS day,
COUNT(1) AS total_count, 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) AS up_count,
(SUM(CASE WHEN "value" >= 0 THEN 1 ELSE 0 END) * 100.0 / COUNT(1)) AS up_rate (SUM(CASE WHEN "value" >= 0 THEN 1 ELSE 0 END) * 100.0 / COUNT(1)) AS up_rate