superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grace...@apache.org
Subject [incubator-superset] branch master updated: [fix][Annotation] Fix override since/until for annotation (#6221)
Date Mon, 29 Oct 2018 22:43:07 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 7d6a429  [fix][Annotation] Fix override since/until for annotation (#6221)
7d6a429 is described below

commit 7d6a4291e162e2959dcffc6f48af05f06cacd91c
Author: Grace Guo <grace.guo@airbnb.com>
AuthorDate: Mon Oct 29 15:43:01 2018 -0700

    [fix][Annotation] Fix override since/until for annotation (#6221)
---
 superset/assets/src/chart/chartAction.js | 7 ++++++-
 superset/assets/src/utils/common.js      | 3 +++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/superset/assets/src/chart/chartAction.js b/superset/assets/src/chart/chartAction.js
index 38e4ad2..2898740 100644
--- a/superset/assets/src/chart/chartAction.js
+++ b/superset/assets/src/chart/chartAction.js
@@ -6,6 +6,7 @@ import { requiresQuery, ANNOTATION_SOURCE_TYPES } from '../modules/AnnotationTyp
 import { addDangerToast } from '../messageToasts/actions';
 import { Logger, LOG_ACTIONS_LOAD_CHART } from '../logger';
 import { getClientErrorObject } from '../modules/utils';
+import { TIME_RANGE_SEPARATOR } from '../utils/common';
 import { t } from '../locales';
 
 export const CHART_UPDATE_STARTED = 'CHART_UPDATE_STARTED';
@@ -66,7 +67,8 @@ export function annotationQueryFailed(annotation, queryResponse, key) {
 export function runAnnotationQuery(annotation, timeout = 60, formData = null, key) {
   return function (dispatch, getState) {
     const sliceKey = key || Object.keys(getState().charts)[0];
-    const fd = formData || getState().charts[sliceKey].latestQueryFormData;
+    // make a copy of formData, not modifying original formData
+    const fd = { ...(formData || getState().charts[sliceKey].latestQueryFormData) };
 
     if (!requiresQuery(annotation.sourceType)) {
       return Promise.resolve();
@@ -75,6 +77,9 @@ export function runAnnotationQuery(annotation, timeout = 60, formData =
null, ke
     const granularity = fd.time_grain_sqla || fd.granularity;
     fd.time_grain_sqla = granularity;
     fd.granularity = granularity;
+    if (fd.time_range) {
+      [fd.since, fd.util] = fd.time_range.split(TIME_RANGE_SEPARATOR);
+    }
 
     const sliceFormData = Object.keys(annotation.overrides).reduce(
       (d, k) => ({
diff --git a/superset/assets/src/utils/common.js b/superset/assets/src/utils/common.js
index 4da740e..9fbe35b 100644
--- a/superset/assets/src/utils/common.js
+++ b/superset/assets/src/utils/common.js
@@ -117,3 +117,6 @@ export function optionFromValue(opt) {
 export const COMMON_ERR_MESSAGES = {
   SESSION_TIMED_OUT: t('Your session timed out, please refresh your page and try again.'),
 };
+
+// time_range separator
+export const TIME_RANGE_SEPARATOR = ' : ';


Mime
View raw message