Added timer to explore v2 and share it with sqllab (#1802)

* Added timer to explore v2 and share it with sqllab

* Fixed js tests

* Add timer to initial load

* Make timer smaller

* nits
This commit is contained in:
vera-liu
2016-12-09 13:39:53 -08:00
committed by GitHub
parent 866cfe5279
commit 8ef730b5fe
9 changed files with 136 additions and 74 deletions

View File

@@ -1,6 +1,7 @@
import { defaultFormData } from '../stores/store';
import * as actions from '../actions/exploreActions';
import { addToArr, removeFromArr, alterInArr } from '../../../utils/reducerUtils';
import { now } from '../../modules/dates';
export const exploreReducer = function (state, action) {
const actionHandlers = {
@@ -113,19 +114,32 @@ export const exploreReducer = function (state, action) {
query: action.viz.query,
data: action.viz.data,
};
const chartUpdateEndTime = now();
return Object.assign(
{},
state,
{
viz: Object.assign({}, state.viz, vizUpdates),
isChartLoading: false,
chartStatus: 'success',
chartUpdateEndTime,
});
},
[actions.CHART_UPDATE_STARTED]() {
return Object.assign({}, state, { isChartLoading: true });
const chartUpdateStartTime = now();
return Object.assign({}, state,
{ chartStatus: 'loading', chartUpdateEndTime: null, chartUpdateStartTime });
},
[actions.CHART_UPDATE_FAILED]() {
return Object.assign({}, state, { isChartLoading: false, chartAlert: action.error });
const chartUpdateEndTime = now();
return Object.assign({}, state,
{ chartStatus: 'failed', chartAlert: action.error, chartUpdateEndTime });
},
[actions.UPDATE_CHART_STATUS]() {
const newState = Object.assign({}, state, { chartStatus: action.status });
if (action.status === 'success' || action.status === 'failed') {
newState.chartUpdateEndTime = now();
}
return newState;
},
[actions.REMOVE_CHART_ALERT]() {
return Object.assign({}, state, { chartAlert: null });