Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 = ' : ';