Skip to content

Commit

Permalink
[fix][Annotation] Fix override since/until for annotation (apache#6221)
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace Guo committed Oct 29, 2018
1 parent 71d6ff4 commit 7d6a429
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion superset/assets/src/chart/chartAction.js
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand All @@ -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) => ({
Expand Down
3 changes: 3 additions & 0 deletions superset/assets/src/utils/common.js
Expand Up @@ -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 = ' : ';

0 comments on commit 7d6a429

Please sign in to comment.