Skip to content

Commit

Permalink
fix: fix monitor data sorting problem, add order by and add created a…
Browse files Browse the repository at this point in the history
…t for fetch monitor data
  • Loading branch information
moonrailgun committed Jan 9, 2024
1 parent f9ea835 commit 023a657
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- CreateIndex
CREATE INDEX "MonitorData_createdAt_idx" ON "MonitorData"("createdAt");
2 changes: 2 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ model MonitorData {
createdAt DateTime @default(now()) @db.Timestamptz(6)
monitor Monitor @relation(fields: [monitorId], references: [id], onUpdate: Cascade, onDelete: Cascade)
@@index([createdAt])
}

// Use for record latest monitor status, for example tls status
Expand Down
3 changes: 3 additions & 0 deletions src/server/model/monitor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export function getMonitorData(
value: true,
createdAt: true,
},
orderBy: {
createdAt: 'asc',
},
});
}

Expand Down

0 comments on commit 023a657

Please sign in to comment.