fix: fix monitor data sorting problem, add order by and add created at for fetch monitor data

This commit is contained in:
moonrailgun 2024-01-09 20:39:38 +08:00
parent f9ea835dac
commit 023a6573a1
3 changed files with 7 additions and 0 deletions

View File

@ -0,0 +1,2 @@
-- CreateIndex
CREATE INDEX "MonitorData_createdAt_idx" ON "MonitorData"("createdAt");

View File

@ -292,6 +292,8 @@ model MonitorData {
createdAt DateTime @default(now()) @db.Timestamptz(6) createdAt DateTime @default(now()) @db.Timestamptz(6)
monitor Monitor @relation(fields: [monitorId], references: [id], onUpdate: Cascade, onDelete: Cascade) monitor Monitor @relation(fields: [monitorId], references: [id], onUpdate: Cascade, onDelete: Cascade)
@@index([createdAt])
} }
// Use for record latest monitor status, for example tls status // Use for record latest monitor status, for example tls status

View File

@ -37,6 +37,9 @@ export function getMonitorData(
value: true, value: true,
createdAt: true, createdAt: true,
}, },
orderBy: {
createdAt: 'asc',
},
}); });
} }