Vitor-Avila commented on code in PR #28176:
URL: https://github.com/apache/superset/pull/28176#discussion_r1589843584
##########
superset/commands/report/base.py:
##########
@@ -76,3 +79,45 @@ def validate_chart_dashboard(
self._properties["dashboard"] = dashboard
elif not update:
exceptions.append(ReportScheduleEitherChartOrDashboardError())
+
+ def validate_report_frequency(
+ self,
+ cron_schedule: str,
+ report_type: str,
+ ) -> None:
+ """
+ Validates if the report scheduled frequency doesn't exceed a limit
+ configured in `config.py`.
+
+ :param cron_schedule: The cron schedule configured.
+ :param report_type: The report type (Alert/Report).
+ """
+ config_key = (
+ "ALERT_MINIMUM_INTERVAL"
+ if report_type == ReportScheduleType.ALERT
+ else "REPORT_MINIMUM_INTERVAL"
+ )
+ minimum_interval = current_app.config.get(config_key, 0)
+
+ if not isinstance(minimum_interval, int):
+ logger.error(
+ "Invalid value for %s: %s", config_key, minimum_interval,
exc_info=True
+ )
+ return
Review Comment:
I decided to avoid raising a `ValidationError` here to prevent blocking
users from creating alerts/reports until the configuration is fixed by an
admin. Open to feedback, tho
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]