superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grace...@apache.org
Subject [incubator-superset] 01/01: [fix] should set chartUpdateEndTime when chart fetch failed or stopped
Date Fri, 26 Oct 2018 20:36:29 GMT
This is an automated email from the ASF dual-hosted git repository.

graceguo pushed a commit to branch gg-AddchartUpdateEndTime
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git

commit 4a6f7401bbc7f7ba0ac0457e5c0f6afe7da289e2
Author: Grace Guo <grace.guo@airbnb.com>
AuthorDate: Fri Oct 26 10:17:46 2018 -0700

    [fix] should set chartUpdateEndTime when chart fetch failed or stopped
---
 .../spec/javascripts/chart/chartReducers_spec.js   | 28 ++++++++++++++++++++++
 superset/assets/src/chart/chartReducer.js          |  2 ++
 2 files changed, 30 insertions(+)

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 0000000..2671df9
--- /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 28953ba..65df6e5 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) {


Mime
View raw message