Fix: Insert empty datapoint on both sides of the gap

Nelson Chan 4 months ago
parent ba730bff24
commit bb708304f8
No known key found for this signature in database

@ -184,16 +184,23 @@ export default {
const diff = Math.abs(beatTime.diff(lastHeartbeatTime)); const diff = Math.abs(beatTime.diff(lastHeartbeatTime));
if (diff > monitorInterval * 1000 * 10) { if (diff > monitorInterval * 1000 * 10) {
// Big gap detected // Big gap detected
const gapX = beatTime.subtract(monitorInterval, "second").format("YYYY-MM-DD HH:mm:ss"); const gapX = [
pingData.push({ lastHeartbeatTime.add(monitorInterval, "second").format("YYYY-MM-DD HH:mm:ss"),
x: gapX, beatTime.subtract(monitorInterval, "second").format("YYYY-MM-DD HH:mm:ss")
y: null, ];
});
downData.push({ for (const x of gapX) {
x: gapX, pingData.push({
y: null, x,
}); y: null,
colorData.push("#000"); });
downData.push({
x,
y: null,
});
colorData.push("#000");
}
} }
} }
@ -262,7 +269,8 @@ export default {
// Insert empty datapoint to separate big gaps // Insert empty datapoint to separate big gaps
if (lastHeartbeatTime && monitorInterval) { if (lastHeartbeatTime && monitorInterval) {
const diff = Math.abs(beatTime.diff(lastHeartbeatTime)); const diff = Math.abs(beatTime.diff(lastHeartbeatTime));
if (diff > monitorInterval * 1000 * 10) { if ((period <= 24 && diff > Math.max(1000 * 60 * 10, monitorInterval * 1000 * 10)) ||
(period > 24 && diff > Math.max(1000 * 60 * 60 * 10, monitorInterval * 1000 * 10)) ) {
// Big gap detected // Big gap detected
// Clear the aggregate buffer // Clear the aggregate buffer
if (aggregateBuffer.length > 0) { if (aggregateBuffer.length > 0) {
@ -271,24 +279,31 @@ export default {
aggregateBuffer = []; aggregateBuffer = [];
} }
const x = this.$root.unixToDateTime(datapoint.timestamp + monitorInterval); const gapX = [
avgPingData.push({ lastHeartbeatTime.subtract(monitorInterval, "second").format("YYYY-MM-DD HH:mm:ss"),
x, this.$root.unixToDateTime(datapoint.timestamp + 60),
y: null, ];
});
minPingData.push({ for (const x of gapX) {
x, avgPingData.push({
y: null, x,
}); y: null,
maxPingData.push({ });
x, minPingData.push({
y: null, x,
}); y: null,
downData.push({ });
x, maxPingData.push({
y: null, x,
}); y: null,
colorData.push("#000"); });
downData.push({
x,
y: null,
});
colorData.push("#000");
}
} }
} }

Loading…
Cancel
Save