From 1ea0d1486632fe3f98a3361927924837b391c38d Mon Sep 17 00:00:00 2001 From: Maciej Bodek Date: Mon, 2 Dec 2024 12:42:42 +0100 Subject: [PATCH] round values --- .../web-console/src/scenes/Editor/Metrics/metric.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/web-console/src/scenes/Editor/Metrics/metric.tsx b/packages/web-console/src/scenes/Editor/Metrics/metric.tsx index 1a26c42f9..d3f3a35b6 100644 --- a/packages/web-console/src/scenes/Editor/Metrics/metric.tsx +++ b/packages/web-console/src/scenes/Editor/Metrics/metric.tsx @@ -49,11 +49,16 @@ const ActionButton = styled(Button)` width: 3rem; ` +const sqlValueToFixed = (value: string, decimals: number = 2) => { + const parsed = parseFloat(value) + return Number(parsed.toFixed(decimals)) as unknown as number +} + const graphDataConfigs = { [MetricType.LATENCY]: { getData: (latency: Latency[]): uPlot.AlignedData => [ latency.map((l) => new Date(l.time).getTime()), - latency.map((l) => parseFloat(l.avg_latency)), + latency.map((l) => sqlValueToFixed(l.avg_latency)), ], yValue: (rawValue: number) => { if (rawValue >= 1000) { @@ -66,7 +71,7 @@ const graphDataConfigs = { [MetricType.ROWS_APPLIED]: { getData: (rowsApplied: RowsApplied[]): uPlot.AlignedData => [ rowsApplied.map((l) => new Date(l.time).getTime()), - rowsApplied.map((l) => parseFloat(l.numOfRowsWritten)), + rowsApplied.map((l) => sqlValueToFixed(l.numOfRowsApplied)), ], yValue: (rawValue: number) => { if (rawValue >= 1e6) { @@ -80,7 +85,7 @@ const graphDataConfigs = { [MetricType.WRITE_AMPLIFICATION]: { getData: (rowsApplied: RowsApplied[]): uPlot.AlignedData => [ rowsApplied.map((l) => new Date(l.time).getTime()), - rowsApplied.map((l) => parseFloat(l.avgWalAmplification)), + rowsApplied.map((l) => sqlValueToFixed(l.avgWalAmplification)), ], yValue: (rawValue: number) => `${rawValue} x`, },