Skip to content
Snippets Groups Projects
Unverified Commit ec84bde2 authored by Tom Robinson's avatar Tom Robinson
Browse files

Run button should ignore cache

parent 3176fbd6
No related branches found
No related tags found
No related merge requests found
......@@ -223,7 +223,7 @@ export const initializeQB = createThunkAction(INITIALIZE_QB, (location, params)
if (card && card.dataset_query && (Query.canRun(card.dataset_query.query) || card.dataset_query.type === "native")) {
// NOTE: timeout to allow Parameters widget to set parameterValues
setTimeout(() =>
dispatch(runQuery(card, false))
dispatch(runQuery(card, { shouldUpdateUrl: false }))
, 0);
}
......@@ -285,7 +285,7 @@ export const cancelEditing = createThunkAction(CANCEL_EDITING, () => {
dispatch(loadMetadataForCard(card));
// we do this to force the indication of the fact that the card should not be considered dirty when the url is updated
dispatch(runQuery(card, false));
dispatch(runQuery(card, { shouldUpdateUrl: false }));
dispatch(updateUrl(card, { dirty: false }));
MetabaseAnalytics.trackEvent("QueryBuilder", "Edit Cancel");
......@@ -458,7 +458,7 @@ export const reloadCard = createThunkAction(RELOAD_CARD, () => {
dispatch(loadMetadataForCard(card));
// we do this to force the indication of the fact that the card should not be considered dirty when the url is updated
dispatch(runQuery(card, false));
dispatch(runQuery(card, { shouldUpdateUrl: false }));
dispatch(updateUrl(card, { dirty: false }));
return card;
......@@ -474,7 +474,7 @@ export const setCardAndRun = createThunkAction(SET_CARD_AND_RUN, (runCard, shoul
dispatch(loadMetadataForCard(card));
dispatch(runQuery(card, shouldUpdateUrl));
dispatch(runQuery(card, { shouldUpdateUrl: shouldUpdateUrl }));
return card;
};
......@@ -788,10 +788,13 @@ export const setQuerySort = createThunkAction(SET_QUERY_SORT, (column) => {
};
});
// runQuery
export const RUN_QUERY = "RUN_QUERY";
export const runQuery = createThunkAction(RUN_QUERY, (card, shouldUpdateUrl = true, parameterValues, dirty) => {
export const runQuery = createThunkAction(RUN_QUERY, (card, {
shouldUpdateUrl = true,
ignoreCache = false, // currently only implemented for saved cards
parameterValues
} = {}) => {
return async (dispatch, getState) => {
const state = getState();
const parameters = getParameters(state);
......@@ -824,8 +827,12 @@ export const runQuery = createThunkAction(RUN_QUERY, (card, shouldUpdateUrl = tr
}
// use the CardApi.query if the query is saved and not dirty so users with view but not create permissions can see it.
if (card && card.id && !isDirty(state) && dirty !== true) {
CardApi.query({ cardId: card.id, parameters: card.dataset_query.parameters }, { cancelled: cancelQueryDeferred.promise }).then(onQuerySuccess, onQueryError);
if (card && card.id != null && !cardIsDirty) {
CardApi.query({
cardId: card.id,
parameters: card.dataset_query.parameters,
ignore_cache: ignoreCache
}, { cancelled: cancelQueryDeferred.promise }).then(onQuerySuccess, onQueryError);
} else {
MetabaseApi.dataset(card.dataset_query, { cancelled: cancelQueryDeferred.promise }).then(onQuerySuccess, onQueryError);
}
......@@ -1053,7 +1060,6 @@ export const onCancelEditing = cancelEditing;
export const setQueryModeFn = setQueryMode;
export const setSortFn = setQuerySort;
export const setQueryFn = setQuery;
export const runQueryFn = runQuery;
export const cancelQueryFn = cancelQuery;
export const setDatabaseFn = setQueryDatabase;
export const setSourceTableFn = setQuerySourceTable;
......
......@@ -90,7 +90,7 @@ export default class NativeQueryEditor extends Component {
nativeDatabases: PropTypes.array.isRequired,
query: PropTypes.object.isRequired,
setQueryFn: PropTypes.func.isRequired,
runQueryFn: PropTypes.func.isRequired,
runQuery: PropTypes.func.isRequired,
setDatabaseFn: PropTypes.func.isRequired,
autocompleteResultsFn: PropTypes.func.isRequired,
isOpen: PropTypes.bool,
......@@ -163,10 +163,10 @@ export default class NativeQueryEditor extends Component {
const selectedText = this._editor.getSelectedText();
if (selectedText) {
const temporaryCard = assocIn(card, ["dataset_query", "native", "query"], selectedText);
this.props.runQueryFn(temporaryCard, false, null, true);
this.props.runQuery(temporaryCard, { shouldUpdateUrl: false });
}
} else {
this.props.runQueryFn();
this.props.runQuery();
}
}
}
......
......@@ -24,7 +24,6 @@ import moment from "moment";
export default class QueryVisualization extends Component {
constructor(props, context) {
super(props, context);
this.runQuery = this.runQuery.bind(this);
this.state = this._getStateFromProps(props);
}
......@@ -44,7 +43,7 @@ export default class QueryVisualization extends Component {
cellClickedFn: PropTypes.func,
isRunning: PropTypes.bool.isRequired,
isRunnable: PropTypes.bool.isRequired,
runQueryFn: PropTypes.func.isRequired,
runQuery: PropTypes.func.isRequired,
cancelQueryFn: PropTypes.func
};
......@@ -79,8 +78,8 @@ export default class QueryVisualization extends Component {
return (display !== "table" && display !== "scalar");
}
runQuery() {
this.props.runQueryFn();
runQuery = () => {
this.props.runQuery(null, { ignoreCache: true });
}
renderHeader() {
......
......@@ -26,7 +26,7 @@ export default class DataReference extends Component {
static propTypes = {
query: PropTypes.object.isRequired,
onClose: PropTypes.func.isRequired,
runQueryFn: PropTypes.func.isRequired,
runQuery: PropTypes.func.isRequired,
setQueryFn: PropTypes.func.isRequired,
setDatabaseFn: PropTypes.func.isRequired,
setSourceTableFn: PropTypes.func.isRequired,
......
......@@ -28,7 +28,7 @@ export default class FieldPane extends Component {
field: PropTypes.object.isRequired,
query: PropTypes.object,
loadTableAndForeignKeysFn: PropTypes.func.isRequired,
runQueryFn: PropTypes.func.isRequired,
runQuery: PropTypes.func.isRequired,
setQueryFn: PropTypes.func.isRequired,
setCardAndRun: PropTypes.func.isRequired
};
......@@ -63,7 +63,7 @@ export default class FieldPane extends Component {
}
Query.addBreakout(query.query, this.props.field.id);
this.props.setQueryFn(query);
this.props.runQueryFn();
this.props.runQuery();
}
newCard() {
......
......@@ -26,7 +26,7 @@ export default class MetricPane extends Component {
metric: PropTypes.object.isRequired,
query: PropTypes.object,
loadTableAndForeignKeysFn: PropTypes.func.isRequired,
runQueryFn: PropTypes.func.isRequired,
runQuery: PropTypes.func.isRequired,
setQueryFn: PropTypes.func.isRequired,
setCardAndRun: PropTypes.func.isRequired
};
......
......@@ -27,7 +27,7 @@ export default class SegmentPane extends Component {
segment: PropTypes.object.isRequired,
query: PropTypes.object,
loadTableAndForeignKeysFn: PropTypes.func.isRequired,
runQueryFn: PropTypes.func.isRequired,
runQuery: PropTypes.func.isRequired,
setQueryFn: PropTypes.func.isRequired,
setCardAndRun: PropTypes.func.isRequired
};
......@@ -53,7 +53,7 @@ export default class SegmentPane extends Component {
}
Query.addFilter(query.query, ["SEGMENT", this.props.segment.id]);
this.props.setQueryFn(query);
this.props.runQueryFn();
this.props.runQuery();
}
newCard() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment