Skip to content

Commit

Permalink
feat(config): Add none force-refresh option for auto refresh (#17039)
Browse files Browse the repository at this point in the history
* feat(config): Add none force-refresh option for auto refresh

* use general config

* fix lint issues

* last lint fix
  • Loading branch information
yongchand committed Oct 14, 2021
1 parent 434b576 commit 7a2e394
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
12 changes: 10 additions & 2 deletions superset-frontend/src/dashboard/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,19 @@ class Header extends React.PureComponent {
});
this.props.addWarningToast(
t(
`This dashboard is currently force refreshing; the next force refresh will be in %s.`,
`This dashboard is currently auto refreshing; the next auto refresh will be in %s.`,
intervalMessage,
),
);

if (dashboardInfo.common.conf.DASHBOARD_AUTO_REFRESH_MODE === 'fetch') {
// force-refresh while auto-refresh in dashboard
return fetchCharts(
affectedCharts,
false,
interval * 0.2,
dashboardInfo.id,
);
}
return fetchCharts(
affectedCharts,
true,
Expand Down
14 changes: 13 additions & 1 deletion superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@
import sys
from collections import OrderedDict
from datetime import date, timedelta
from typing import Any, Callable, Dict, List, Optional, Type, TYPE_CHECKING, Union
from typing import (
Any,
Callable,
Dict,
List,
Literal,
Optional,
Type,
TYPE_CHECKING,
Union,
)

from cachelib.base import BaseCache
from celery.schedules import crontab
Expand Down Expand Up @@ -692,6 +702,8 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]:
SQLLAB_SAVE_WARNING_MESSAGE = None
SQLLAB_SCHEDULE_WARNING_MESSAGE = None

# Force refresh while auto-refresh in dashboard
DASHBOARD_AUTO_REFRESH_MODE: Literal["fetch", "force"] = "force"

# Default celery config is to use SQLA as a broker, in a production setting
# you'll want to use a proper broker as specified here:
Expand Down
1 change: 1 addition & 0 deletions superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"SQLALCHEMY_DOCS_URL",
"SQLALCHEMY_DISPLAY_TEXT",
"GLOBAL_ASYNC_QUERIES_WEBSOCKET_URL",
"DASHBOARD_AUTO_REFRESH_MODE",
)
logger = logging.getLogger(__name__)

Expand Down

0 comments on commit 7a2e394

Please sign in to comment.