mirror of
https://github.com/apache/superset.git
synced 2026-04-21 00:54:44 +00:00
help sqllab forget the past
This commit is contained in:
@@ -8,6 +8,7 @@ const $ = require('jquery');
|
||||
|
||||
const QUERY_UPDATE_FREQ = 2000;
|
||||
const QUERY_UPDATE_BUFFER_MS = 5000;
|
||||
const QUERY_POLL_WINDOW = 21600000; // 6 hours.
|
||||
|
||||
class QueryAutoRefresh extends React.PureComponent {
|
||||
componentWillMount() {
|
||||
@@ -17,11 +18,11 @@ class QueryAutoRefresh extends React.PureComponent {
|
||||
this.stopTimer();
|
||||
}
|
||||
shouldCheckForQueries() {
|
||||
// if there are started or running queries, this method should return true
|
||||
// if there are started or running queries < 6 hours old, this method should return true
|
||||
const { queries } = this.props;
|
||||
const queryKeys = Object.keys(queries);
|
||||
const queriesAsArray = queryKeys.map(key => queries[key]);
|
||||
return queriesAsArray.some(q =>
|
||||
return Object.values(queries)
|
||||
.filter(q => (q.startDttm >= this.props.queriesLastUpdate - QUERY_POLL_WINDOW))
|
||||
.some(q =>
|
||||
['running', 'started', 'pending', 'fetching'].indexOf(q.state) >= 0);
|
||||
}
|
||||
startTimer() {
|
||||
@@ -34,7 +35,7 @@ class QueryAutoRefresh extends React.PureComponent {
|
||||
this.timer = null;
|
||||
}
|
||||
stopwatch() {
|
||||
// only poll /superset/queries/ if there are started or running queries
|
||||
// only poll /superset/queries/ if there are started or running queries started <6 hours ago
|
||||
if (this.shouldCheckForQueries()) {
|
||||
const url = `/superset/queries/${this.props.queriesLastUpdate - QUERY_UPDATE_BUFFER_MS}`;
|
||||
$.getJSON(url, (data) => {
|
||||
|
||||
Reference in New Issue
Block a user