[fix][Annotation] Fix override since/until for annotation (#6221)

This commit is contained in:
Grace Guo
2018-10-29 15:43:01 -07:00
committed by GitHub
parent 71d6ff40d0
commit 7d6a4291e1
2 changed files with 9 additions and 1 deletions

View File

@@ -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) => ({

View File

@@ -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 = ' : ';