fix sort order, checks need to be queried in desc order due to the way that works.

This commit is contained in:
Alex Holliday committed 2024-11-26 09:34:47 +08:00
1 parent 0b3df9afce
commit bb2f2450fd
1 file changed
+8 -7
@@ -207,7 +207,8 @@ const InfrastructureDetails = () => {
// end height calculations // end height calculations
const buildStatBoxes = (monitor) => { const buildStatBoxes = (monitor) => {
let latestCheck = monitor?.checks[monitor?.checks.length - 1] ?? null; let latestCheck = monitor?.checks[0] ?? null;
console.log(latestCheck);
if (latestCheck === null) return []; if (latestCheck === null) return [];
// Extract values from latest check // Extract values from latest check
@@ -270,7 +271,7 @@ const InfrastructureDetails = () => {
}; };
const buildGaugeBoxConfigs = (monitor) => { const buildGaugeBoxConfigs = (monitor) => {
let latestCheck = monitor?.checks[monitor?.checks.length - 1] ?? null; let latestCheck = monitor?.checks[0] ?? null;
if (latestCheck === null) return []; if (latestCheck === null) return [];
// Extract values from latest check // Extract values from latest check
@@ -349,13 +350,13 @@ const InfrastructureDetails = () => {
}; };
const buildAreaChartConfigs = (monitor) => { const buildAreaChartConfigs = (monitor) => {
let latestCheck = monitor?.checks[monitor?.checks.length - 1] ?? null; let latestCheck = monitor?.checks[0] ?? null;
if (latestCheck === null) return []; if (latestCheck === null) return [];
const tempData = buildTemps(monitor); const tempData = buildTemps(monitor);
return [ return [
{ {
type: "memory", type: "memory",
data: monitor?.checks ?? [], data: monitor?.checks?.reverse() ?? [],
dataKeys: ["memory.usage_percent"], dataKeys: ["memory.usage_percent"],
heading: "Memory usage", heading: "Memory usage",
strokeColor: theme.palette.primary.main, strokeColor: theme.palette.primary.main,
@@ -374,7 +375,7 @@ const InfrastructureDetails = () => {
}, },
{ {
type: "cpu", type: "cpu",
data: monitor?.checks ?? [], data: monitor?.checks?.reverse() ?? [],
dataKeys: ["cpu.usage_percent"], dataKeys: ["cpu.usage_percent"],
heading: "CPU usage", heading: "CPU usage",
strokeColor: theme.palette.success.main, strokeColor: theme.palette.success.main,
@@ -410,7 +411,7 @@ const InfrastructureDetails = () => {
}, },
...(latestCheck?.disk?.map((disk, idx) => ({ ...(latestCheck?.disk?.map((disk, idx) => ({
type: "disk", type: "disk",
data: monitor?.checks ?? [], data: monitor?.checks?.reverse() ?? [],
diskIndex: idx, diskIndex: idx,
dataKeys: [`disk[${idx}].usage_percent`], dataKeys: [`disk[${idx}].usage_percent`],
heading: `Disk${idx} usage`, heading: `Disk${idx} usage`,
@@ -439,7 +440,7 @@ const InfrastructureDetails = () => {
const response = await networkService.getStatsByMonitorId({ const response = await networkService.getStatsByMonitorId({
authToken: authToken, authToken: authToken,
monitorId: monitorId, monitorId: monitorId,
sortOrder: "asc", sortOrder: null,
limit: null, limit: null,
dateRange: dateRange, dateRange: dateRange,
numToDisplay: 50, numToDisplay: 50,