@@ -1016,15 +1016,13 @@ class RuleFormContainer extends DeprecatedAsyncComponent<Props, State> {
1016
1016
this . setState ( { historicalData} , ( ) => this . fetchAnomalies ( ) ) ;
1017
1017
}
1018
1018
1019
- TimeWindowsAreConsistent ( ) {
1020
- const { currentData, historicalData, timeWindow} = this . state ;
1021
- const currentDataPoint1 = currentData [ 1 ] ;
1022
- const currentDataPoint0 = currentData [ 0 ] ;
1019
+ timeWindowsAreConsistent ( ) {
1020
+ const { currentData = [ ] , historicalData = [ ] , timeWindow} = this . state ;
1021
+ const [ currentDataPoint0 , currentDataPoint1 ] = currentData ;
1023
1022
if ( ! currentDataPoint0 || ! currentDataPoint1 ) {
1024
1023
return false ;
1025
1024
}
1026
- const historicalDataPoint1 = historicalData [ 1 ] ;
1027
- const historicalDataPoint0 = historicalData [ 0 ] ;
1025
+ const [ historicalDataPoint0 , historicalDataPoint1 ] = historicalData ;
1028
1026
if ( ! historicalDataPoint0 || ! historicalDataPoint1 ) {
1029
1027
return false ;
1030
1028
}
@@ -1040,7 +1038,8 @@ class RuleFormContainer extends DeprecatedAsyncComponent<Props, State> {
1040
1038
comparisonType !== AlertRuleComparisonType . DYNAMIC ||
1041
1039
! ( Array . isArray ( currentData ) && Array . isArray ( historicalData ) ) ||
1042
1040
currentData . length === 0 ||
1043
- historicalData . length === 0
1041
+ historicalData . length === 0 ||
1042
+ ! this . timeWindowsAreConsistent ( )
1044
1043
) {
1045
1044
return ;
1046
1045
}
@@ -1082,10 +1081,7 @@ class RuleFormContainer extends DeprecatedAsyncComponent<Props, State> {
1082
1081
`/organizations/${ organization . slug } /events/anomalies/` ,
1083
1082
{ method : 'POST' , data : params }
1084
1083
) ;
1085
- // don't set the anomalies if historical and current data have incorrect time windows
1086
- if ( ! this . TimeWindowsAreConsistent ( ) ) {
1087
- this . setState ( { anomalies} ) ;
1088
- }
1084
+ this . setState ( { anomalies} ) ;
1089
1085
} catch ( e ) {
1090
1086
let chartErrorMessage : string | undefined ;
1091
1087
if ( e . responseJSON ) {
0 commit comments