Skip to content

Commit

Permalink
🐛 fix: lastCheck with time
Browse files Browse the repository at this point in the history
  • Loading branch information
yunsii committed Mar 18, 2024
1 parent 4a21af2 commit 99840ce
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/helpers/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export function getChecksItemRenderStatus(monitorAllData: MonitorAllData, date:

const checksItemStatus = getChecksItemStatus(targetDateChecksItem)

if (monitorAllData.lastCheck.operational === false && date === getDate()) {
if (monitorAllData.lastCheck.operational === false
&& date === getDate(monitorAllData.lastCheck.time ? new Date(monitorAllData.lastCheck.time) : null)
) {
status = 'latest-incident'
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/worker/_helpers/datetime.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function getDate(date?: Date) {
export function getDate(date?: Date | null) {
return (date ?? new Date()).toISOString().split('T')[0]
}

Expand Down
1 change: 1 addition & 0 deletions src/worker/_helpers/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const WORKER_SUBREQUESTS_LIMIT = 50
export const DATA_KEY = 'data-v1'

export interface MonitorLastCheck {
time?: number
operational: boolean
status: number
statusText: string
Expand Down
1 change: 1 addition & 0 deletions src/worker/cron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export async function handleCronTrigger(event: FetchEvent) {
status: checkResponse.status,
statusText: checkResponse.statusText,
operational: monitorOperational,
time: Date.now(),
}

const targetMonitorHistoryDataChecksItem = kvData.monitorHistoryData?.[monitor.id]?.checks.find((item) => {
Expand Down

0 comments on commit 99840ce

Please sign in to comment.