Skip to content

Commit

Permalink
Use default value if window size not specified
Browse files Browse the repository at this point in the history
Signed-off-by: Siddhant Deshmukh <[email protected]>
  • Loading branch information
deshsidd committed Nov 12, 2024
1 parent 8d343eb commit 771083d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions public/pages/TopNQueries/TopNQueries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ const TopNQueries = ({
const { latency, cpu, memory } =
resp?.response?.persistent?.search?.insights?.top_queries || {};
if (latency !== undefined && latency.enabled === 'true') {
const [time, timeUnits] = latency.window_size.match(/\D+|\d+/g);
const [time, timeUnits] = latency.window_size
? latency.window_size.match(/\D+|\d+/g)
: ['1', 'm'];
setMetricSettings('latency', {
isEnabled: true,
currTopN: latency.top_n_size,
Expand All @@ -192,7 +194,9 @@ const TopNQueries = ({
});
}
if (cpu !== undefined && cpu.enabled === 'true') {
const [time, timeUnits] = cpu.window_size.match(/\D+|\d+/g);
const [time, timeUnits] = cpu.window_size
? cpu.window_size.match(/\D+|\d+/g)
: ['1', 'm'];
setMetricSettings('cpu', {
isEnabled: true,
currTopN: cpu.top_n_size,
Expand All @@ -201,7 +205,9 @@ const TopNQueries = ({
});
}
if (memory !== undefined && memory.enabled === 'true') {
const [time, timeUnits] = memory.window_size.match(/\D+|\d+/g);
const [time, timeUnits] = memory.window_size
? memory.window_size.match(/\D+|\d+/g)
: ['1', 'm'];
setMetricSettings('memory', {
isEnabled: true,
currTopN: memory.top_n_size,
Expand Down

0 comments on commit 771083d

Please sign in to comment.