Merge pull request #568 from bluewave-labs/feat/monitor-details-performance
Prep monitor details page for #567
This commit is contained in:
commit
7928bd7822
5 files changed
+102
-84
No files matched your search
@@ -47,37 +47,9 @@ const MonitorDetailsAreaChart = ({ checks, filter }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const filterChecks = (checks, filter, numToDisplay) => {
|
||||
const limits = {
|
||||
day: 24 * 60 * 60 * 1000,
|
||||
week: 24 * 60 * 60 * 1000 * 7,
|
||||
month: 24 * 60 * 60 * 1000 * 30, //TODO better monthly calculations
|
||||
};
|
||||
|
||||
const now = new Date().getTime();
|
||||
let result = [];
|
||||
for (let i = 0; i < checks.length; i++) {
|
||||
const checkTime = new Date(checks[i].createdAt).getTime();
|
||||
if (now - checkTime < limits[filter]) {
|
||||
result.push(checks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// If more than numToDisplay checks, pick every nth check
|
||||
if (result.length > numToDisplay) {
|
||||
const n = Math.ceil(result.length / numToDisplay);
|
||||
result = result.filter((_, idx) => {
|
||||
return idx % n === 0;
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
let normalizedChecks = [];
|
||||
if (checks && checks.length > 0) {
|
||||
const filteredChecks = filterChecks(checks, filter, 75);
|
||||
normalizedChecks = NormalizeData(filteredChecks, 10, 100);
|
||||
normalizedChecks = NormalizeData(checks, 10, 100);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user