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 {
1919 * Calculate queries per second metrics from chart data
2020 */
2121export 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 ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+
13import { ChevronDown } from '@gravity-ui/icons' ;
24import type { ButtonProps } from '@gravity-ui/uikit' ;
35import { 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 ) } >
You can’t perform that action at this time.
0 commit comments