Skip to content

Commit

Permalink
Fix asset uptime carryover (#5896)
Browse files Browse the repository at this point in the history
* Fix asset uptime carryover

* Fix more issues
  • Loading branch information
Ashesh3 committed Jul 22, 2023
1 parent bddeda6 commit c3aedbf
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/Components/Common/Uptime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,27 @@ export default function Uptime(props: { assetId: string }) {
timestamp: moment()
.subtract(i, "days")
.startOf("day")
.toISOString(),
.format("YYYY-MM-DDTHH:mm:ss.SSSSSSZ"),
});
}
} else {
if (
recordsByDayBefore[i].filter(
(r) => moment(r.timestamp).get("hour") < 8
).length === 0
) {
recordsByDayBefore[i].unshift({
id: "",
asset: { id: "", name: "" },
created_date: "",
modified_date: "",
status: statusToCarryOver,
timestamp: moment()
.subtract(i, "days")
.startOf("day")
.format("YYYY-MM-DDTHH:mm:ss.SSSSSSZ"),
});
}
statusToCarryOver =
recordsByDayBefore[i][recordsByDayBefore[i].length - 1].status;
}
Expand Down Expand Up @@ -299,7 +316,9 @@ export default function Uptime(props: { assetId: string }) {
recordsInPeriodCache[i] = recordsInPeriod;
if (recordsInPeriod.length === 0) {
const previousLatestRecord =
recordsInPeriodCache[i - 1]?.[dayRecords.length - 1];
recordsInPeriodCache[i - 1]?.[
recordsInPeriodCache[i - 1]?.length - 1
];
if (
moment(previousLatestRecord?.timestamp)
.hour(end)
Expand All @@ -315,6 +334,7 @@ export default function Uptime(props: { assetId: string }) {
previousLatestRecord?.status as keyof typeof STATUS_COLORS
] ?? STATUS_COLORS["Not Monitored"]
);
recordsInPeriodCache[i] = [previousLatestRecord];
} else {
statusColors.push(STATUS_COLORS["Not Monitored"]);
}
Expand Down

0 comments on commit c3aedbf

Please sign in to comment.