graceguo-supercat closed pull request #6221: [fix][Annotation] Fix override 
since/until for annotation
URL: https://github.com/apache/incubator-superset/pull/6221
 
 
   

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/src/chart/chartAction.js 
b/superset/assets/src/chart/chartAction.js
index 38e4ad2fb8..2898740818 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 4da740e193..9fbe35bcb9 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 = ' : ';


 

----------------------------------------------------------------
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]

Reply via email to