graceguo-supercat closed pull request #6203: [fix] should set
chartUpdateEndTime when chart fetch failed or stopped
URL: https://github.com/apache/incubator-superset/pull/6203
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/superset/assets/spec/javascripts/chart/chartReducers_spec.js
b/superset/assets/spec/javascripts/chart/chartReducers_spec.js
new file mode 100644
index 0000000000..2671df9226
--- /dev/null
+++ b/superset/assets/spec/javascripts/chart/chartReducers_spec.js
@@ -0,0 +1,28 @@
+import chartReducer, { chart } from '../../../src/chart/chartReducer';
+import * as actions from '../../../src/chart/chartAction';
+
+
+describe('chart reducers', () => {
+ const chartKey = 1;
+ let testChart;
+ let charts;
+ beforeEach(() => {
+ testChart = {
+ ...chart,
+ id: chartKey,
+ };
+ charts = { [chartKey]: testChart };
+ });
+
+ it('should update endtime on fail', () => {
+ const newState = chartReducer(charts,
actions.chartUpdateStopped(chartKey));
+ expect(newState[chartKey].chartUpdateEndTime).toBeGreaterThan(0);
+ expect(newState[chartKey].chartStatus).toEqual('stopped');
+ });
+
+ it('should update endtime on timeout', () => {
+ const newState = chartReducer(charts,
actions.chartUpdateTimeout('timeout', 60, chartKey));
+ expect(newState[chartKey].chartUpdateEndTime).toBeGreaterThan(0);
+ expect(newState[chartKey].chartStatus).toEqual('failed');
+ });
+});
diff --git a/superset/assets/src/chart/chartReducer.js
b/superset/assets/src/chart/chartReducer.js
index 28953babd8..65df6e5082 100644
--- a/superset/assets/src/chart/chartReducer.js
+++ b/superset/assets/src/chart/chartReducer.js
@@ -45,6 +45,7 @@ export default function chartReducer(charts = {}, action) {
return { ...state,
chartStatus: 'stopped',
chartAlert: t('Updating chart was stopped'),
+ chartUpdateEndTime: now(),
};
},
[actions.CHART_RENDERING_SUCCEEDED](state) {
@@ -68,6 +69,7 @@ export default function chartReducer(charts = {}, action) {
'or you are simply querying a data source that is too large ' +
'to be processed within the timeout range. ' +
'If that is the case, we recommend that you summarize your data
further.')),
+ chartUpdateEndTime: now(),
};
},
[actions.CHART_UPDATE_FAILED](state) {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]