File tree Expand file tree Collapse file tree 2 files changed +17
-12
lines changed Expand file tree Collapse file tree 2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -19,19 +19,18 @@ export interface MetricCalculationResult {
19
19
* Calculate queries per second metrics from chart data
20
20
*/
21
21
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
+
22
27
if ( ! data ) {
23
- return {
24
- value : FALLBACK_VALUE . toFixed ( 0 ) ,
25
- trend : { value : FALLBACK_VALUE , direction : TrendDirection . Up } ,
26
- } ;
28
+ return emptyFallback ;
27
29
}
28
30
29
31
// Safe array access with length validation
30
32
if ( data . length === 0 ) {
31
- return {
32
- value : FALLBACK_VALUE . toFixed ( 0 ) ,
33
- trend : { value : FALLBACK_VALUE , direction : TrendDirection . Up } ,
34
- } ;
33
+ return emptyFallback ;
35
34
}
36
35
37
36
const current = data [ data . length - 1 ] ?? FALLBACK_VALUE ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
1
3
import { ChevronDown } from '@gravity-ui/icons' ;
2
4
import type { ButtonProps } from '@gravity-ui/uikit' ;
3
5
import { Button , DropdownMenu , Icon } from '@gravity-ui/uikit' ;
@@ -25,10 +27,14 @@ export const TimeFrameDropdown = ({
25
27
size = 's' ,
26
28
view = 'flat-secondary' ,
27
29
} : 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
+ ) ;
32
38
33
39
const renderSwitcher = ( props : ButtonProps ) => (
34
40
< Button { ...props } size = { size } view = { view } className = { b ( null , className ) } >
You can’t perform that action at this time.
0 commit comments