refactor: enhance code readability by adding comments for previous status duration calculation

This commit is contained in:
Nawaz Dhandala
2025-12-04 08:59:04 +00:00
parent 0b32408bf2
commit d10bcd2edd

View File

@@ -115,11 +115,15 @@ RunCron(
},
});
// Calculate how long the monitor was in the previous status
// Use startsAt if available, otherwise fall back to createdAt
const previousStartTime: Date | undefined = previousTimeline.startsAt || previousTimeline.createdAt;
const currentStartTime: Date | undefined = monitorStatusTimeline.startsAt || monitorStatusTimeline.createdAt;
/*
* Calculate how long the monitor was in the previous status
* Use startsAt if available, otherwise fall back to createdAt
*/
const previousStartTime: Date | undefined =
previousTimeline.startsAt || previousTimeline.createdAt;
const currentStartTime: Date | undefined =
monitorStatusTimeline.startsAt || monitorStatusTimeline.createdAt;
if (previousStartTime && currentStartTime) {
const durationInSeconds: number =
OneUptimeDate.getDifferenceInSeconds(