mirror of https://github.com/apache/superset.git
fix: [alert] allow decimal for alert threshold value (#17751)
* fix: [alert] add tooltip message for alert threshold value * support decimal value for alert condition threshold * add integration test
This commit is contained in:
parent
4beaa81de3
commit
c5af7a48df
|
@ -54,6 +54,7 @@ import {
|
|||
Operator,
|
||||
Recipient,
|
||||
} from 'src/views/CRUD/alert/types';
|
||||
import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls';
|
||||
import { AlertReportCronScheduler } from './components/AlertReportCronScheduler';
|
||||
import { NotificationMethod } from './components/NotificationMethod';
|
||||
|
||||
|
@ -1183,7 +1184,12 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
|
|||
</StyledInputContainer>
|
||||
<StyledInputContainer>
|
||||
<div className="control-label">
|
||||
{t('Value')}
|
||||
{t('Value')}{' '}
|
||||
<InfoTooltipWithTrigger
|
||||
tooltip={t(
|
||||
'Threshold value should be double precision number',
|
||||
)}
|
||||
/>
|
||||
<span className="required">*</span>
|
||||
</div>
|
||||
<div className="input-container">
|
||||
|
|
|
@ -103,7 +103,7 @@ class ValidatorConfigJSONSchema(Schema):
|
|||
description=validator_config_json_op_description,
|
||||
validate=validate.OneOf(choices=["<", "<=", ">", ">=", "==", "!="]),
|
||||
)
|
||||
threshold = fields.Integer()
|
||||
threshold = fields.Float()
|
||||
|
||||
|
||||
class ReportRecipientConfigJSONSchema(Schema):
|
||||
|
|
|
@ -266,6 +266,9 @@ def test_operator_validator(setup_database):
|
|||
# Test passing with result that equals threshold
|
||||
assert operator_validator(alert2, '{"op": "==", "threshold": 55}') is True
|
||||
|
||||
# Test passing with result that equals decimal threshold
|
||||
assert operator_validator(alert2, '{"op": ">", "threshold": 54.999}') is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"description, query, validator_type, config",
|
||||
|
|
|
@ -411,7 +411,16 @@ def create_alert_slack_chart_grace(request):
|
|||
|
||||
|
||||
@pytest.fixture(
|
||||
params=["alert1", "alert2", "alert3", "alert4", "alert5", "alert6", "alert7",]
|
||||
params=[
|
||||
"alert1",
|
||||
"alert2",
|
||||
"alert3",
|
||||
"alert4",
|
||||
"alert5",
|
||||
"alert6",
|
||||
"alert7",
|
||||
"alert8",
|
||||
]
|
||||
)
|
||||
def create_alert_email_chart(request):
|
||||
param_config = {
|
||||
|
@ -450,6 +459,11 @@ def create_alert_email_chart(request):
|
|||
"validator_type": ReportScheduleValidatorType.OPERATOR,
|
||||
"validator_config_json": '{"op": "!=", "threshold": 11}',
|
||||
},
|
||||
"alert8": {
|
||||
"sql": "SELECT 55 as metric",
|
||||
"validator_type": ReportScheduleValidatorType.OPERATOR,
|
||||
"validator_config_json": '{"op": ">", "threshold": 54.999}',
|
||||
},
|
||||
}
|
||||
with app.app_context():
|
||||
chart = db.session.query(Slice).first()
|
||||
|
|
Loading…
Reference in New Issue