Skip to content

Commit 5c6dcbe

Browse files
committed
fix: nanofix
1 parent 43794c8 commit 5c6dcbe

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/components/QueriesActivityBar/utils.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,18 @@ export interface MetricCalculationResult {
1919
* Calculate queries per second metrics from chart data
2020
*/
2121
export const calculateQueriesPerSecond = (data?: (number | null)[]): MetricCalculationResult => {
22+
const emptyFallback = {
23+
value: FALLBACK_VALUE.toFixed(0),
24+
trend: {value: FALLBACK_VALUE, direction: TrendDirection.Up},
25+
};
26+
2227
if (!data) {
23-
return {
24-
value: FALLBACK_VALUE.toFixed(0),
25-
trend: {value: FALLBACK_VALUE, direction: TrendDirection.Up},
26-
};
28+
return emptyFallback;
2729
}
2830

2931
// Safe array access with length validation
3032
if (data.length === 0) {
31-
return {
32-
value: FALLBACK_VALUE.toFixed(0),
33-
trend: {value: FALLBACK_VALUE, direction: TrendDirection.Up},
34-
};
33+
return emptyFallback;
3534
}
3635

3736
const current = data[data.length - 1] ?? FALLBACK_VALUE;

src/components/TimeFrameDropdown/TimeFrameDropdown.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import React from 'react';
2+
13
import {ChevronDown} from '@gravity-ui/icons';
24
import type {ButtonProps} from '@gravity-ui/uikit';
35
import {Button, DropdownMenu, Icon} from '@gravity-ui/uikit';
@@ -25,10 +27,14 @@ export const TimeFrameDropdown = ({
2527
size = 's',
2628
view = 'flat-secondary',
2729
}: TimeFrameDropdownProps) => {
28-
const items = Object.keys(TIMEFRAMES).map((timeFrame) => ({
29-
text: i18n(timeFrame as TimeFrame),
30-
action: () => onChange(timeFrame as TimeFrame),
31-
}));
30+
const items = React.useMemo(
31+
() =>
32+
Object.keys(TIMEFRAMES).map((timeFrame) => ({
33+
text: i18n(timeFrame as TimeFrame),
34+
action: () => onChange(timeFrame as TimeFrame),
35+
})),
36+
[onChange],
37+
);
3238

3339
const renderSwitcher = (props: ButtonProps) => (
3440
<Button {...props} size={size} view={view} className={b(null, className)}>

0 commit comments

Comments
 (0)