You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by yo...@apache.org on 2021/03/17 03:41:21 UTC
[superset] branch datefilter_debounce created (now 0976a9c)
This is an automated email from the ASF dual-hosted git repository.
yongjiezhao pushed a change to branch datefilter_debounce
in repository https://gitbox.apache.org/repos/asf/superset.git.
at 0976a9c chore(explore): added debounce in DateFilter
This branch includes the following new commits:
new 0976a9c chore(explore): added debounce in DateFilter
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[superset] 01/01: chore(explore): added debounce in DateFilter
Posted by yo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
yongjiezhao pushed a commit to branch datefilter_debounce
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 0976a9c3f19520b7f51537c02b36c522642e2f21
Author: Yongjie Zhao <yo...@gmail.com>
AuthorDate: Wed Mar 17 11:39:58 2021 +0800
chore(explore): added debounce in DateFilter
---
.../controls/DateFilterControl/DateFilterLabel.tsx | 28 +++++++++++++---------
superset/utils/date_parser.py | 2 +-
superset/views/api.py | 6 ++++-
3 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx b/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx
index 485952a..98a5645 100644
--- a/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx
+++ b/superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx
@@ -39,6 +39,8 @@ import Icon from 'src/components/Icon';
import { Select } from 'src/components/Select';
import { Tooltip } from 'src/common/components/Tooltip';
import { DEFAULT_TIME_RANGE } from 'src/explore/constants';
+import { useDebouncedEffect } from 'src/explore/exploreUtils';
+import { SLOW_DEBOUNCE } from 'src/constants';
import { SelectOptionType, FrameType } from './types';
import {
@@ -220,17 +222,21 @@ export default function DateFilterLabel(props: DateFilterControlProps) {
});
}, [value]);
- useEffect(() => {
- fetchTimeRange(timeRangeValue, endpoints).then(({ value, error }) => {
- if (error) {
- setEvalResponse(error || '');
- setValidTimeRange(false);
- } else {
- setEvalResponse(value || '');
- setValidTimeRange(true);
- }
- });
- }, [timeRangeValue]);
+ useDebouncedEffect(
+ () => {
+ fetchTimeRange(timeRangeValue, endpoints).then(({ value, error }) => {
+ if (error) {
+ setEvalResponse(error || '');
+ setValidTimeRange(false);
+ } else {
+ setEvalResponse(value || '');
+ setValidTimeRange(true);
+ }
+ });
+ },
+ SLOW_DEBOUNCE,
+ [timeRangeValue],
+ );
function onSave() {
onChange(timeRangeValue);
diff --git a/superset/utils/date_parser.py b/superset/utils/date_parser.py
index 15e021a..30fce84 100644
--- a/superset/utils/date_parser.py
+++ b/superset/utils/date_parser.py
@@ -85,7 +85,7 @@ def parse_human_datetime(human_readable: str) -> datetime:
parsed_dttm, parsed_flags = cal.parseDT(human_readable)
# 0 == not parsed at all
if parsed_flags == 0:
- logger.exception(ex)
+ logger.debug(ex)
raise TimeRangeParseFailError(human_readable)
# when time is not extracted, we 'reset to midnight'
if parsed_flags & 2 == 0:
diff --git a/superset/views/api.py b/superset/views/api.py
index 7df1c5e..80cb5b6 100644
--- a/superset/views/api.py
+++ b/superset/views/api.py
@@ -24,6 +24,10 @@ from flask_appbuilder.api import rison
from flask_appbuilder.security.decorators import has_access_api
from superset import db, event_logger
+from superset.charts.commands.exceptions import (
+ TimeRangeParseFailError,
+ TimeRangeUnclearError,
+)
from superset.common.query_context import QueryContext
from superset.legacy import update_time_range
from superset.models.slice import Slice
@@ -93,6 +97,6 @@ class Api(BaseSupersetView):
"timeRange": time_range,
}
return self.json_response({"result": result})
- except ValueError as error:
+ except (ValueError, TimeRangeParseFailError, TimeRangeUnclearError) as error:
error_msg = {"message": f"Unexpected time range: {error}"}
return self.json_response(error_msg, 400)