mirror of
https://github.com/getredash/redash.git
synced 2026-05-11 18:01:55 -04:00
use the textless endpoint (/api/queries/:id/results) for pristine
queriest
This commit is contained in:
@@ -26,7 +26,7 @@ function QueryViewCtrl(
|
||||
DataSource,
|
||||
Visualization,
|
||||
) {
|
||||
function getQueryResult(maxAge, selectedQueryText) {
|
||||
function getQueryResult(maxAge, selectedQueryText, isDirty) {
|
||||
if (maxAge === undefined) {
|
||||
maxAge = $location.search().maxAge;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ function QueryViewCtrl(
|
||||
}
|
||||
|
||||
$scope.showLog = false;
|
||||
$scope.queryResult = $scope.query.getQueryResult(maxAge, selectedQueryText);
|
||||
$scope.queryResult = $scope.query.getQueryResult(maxAge, selectedQueryText, isDirty);
|
||||
}
|
||||
|
||||
function getDataSourceId() {
|
||||
@@ -118,7 +118,7 @@ function QueryViewCtrl(
|
||||
return;
|
||||
}
|
||||
|
||||
getQueryResult(0, $scope.selectedQueryText);
|
||||
getQueryResult(0, $scope.selectedQueryText, $scope.isDirty);
|
||||
$scope.lockButton(true);
|
||||
$scope.cancelling = false;
|
||||
Events.record('execute', 'query', $scope.query.id);
|
||||
|
||||
@@ -531,6 +531,30 @@ function QueryResultService($resource, $timeout, $q, QueryResultError) {
|
||||
return `${queryName.replace(/ /g, '_') + moment(this.getUpdatedAt()).format('_YYYY_MM_DD')}.${fileType}`;
|
||||
}
|
||||
|
||||
static getByQueryId(id, parameters, maxAge) {
|
||||
const queryResult = new QueryResult();
|
||||
|
||||
$resource('api/queries/:id/results', { id: '@id' }, { post: { method: 'POST' } }).post(
|
||||
{
|
||||
id,
|
||||
parameters,
|
||||
max_age: maxAge,
|
||||
},
|
||||
(response) => {
|
||||
queryResult.update(response);
|
||||
|
||||
if ('job' in response) {
|
||||
queryResult.refreshStatus(id);
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
handleErrorResponse(queryResult, error);
|
||||
},
|
||||
);
|
||||
|
||||
return queryResult;
|
||||
}
|
||||
|
||||
static get(dataSourceId, query, parameters, maxAge, queryId) {
|
||||
const queryResult = new QueryResult();
|
||||
|
||||
|
||||
@@ -429,7 +429,7 @@ function QueryResource(
|
||||
return this.getParameters().isRequired();
|
||||
};
|
||||
|
||||
QueryService.prototype.getQueryResult = function getQueryResult(maxAge, selectedQueryText) {
|
||||
QueryService.prototype.getQueryResult = function getQueryResult(maxAge, selectedQueryText, isDirty) {
|
||||
if (!this.query) {
|
||||
return new QueryResultError("Can't execute empty query.");
|
||||
}
|
||||
@@ -454,26 +454,30 @@ function QueryResource(
|
||||
});
|
||||
}
|
||||
|
||||
if (parameters.isRequired()) {
|
||||
// Need to clear latest results, to make sure we don't use results for different params.
|
||||
this.latest_query_data = null;
|
||||
this.latest_query_data_id = null;
|
||||
}
|
||||
if (isDirty) {
|
||||
if (parameters.isRequired()) {
|
||||
// Need to clear latest results, to make sure we don't use results for different params.
|
||||
this.latest_query_data = null;
|
||||
this.latest_query_data_id = null;
|
||||
}
|
||||
|
||||
if (this.latest_query_data && maxAge !== 0) {
|
||||
if (!this.queryResult) {
|
||||
this.queryResult = new QueryResult({
|
||||
query_result: this.latest_query_data,
|
||||
});
|
||||
if (this.latest_query_data && maxAge !== 0) {
|
||||
if (!this.queryResult) {
|
||||
this.queryResult = new QueryResult({
|
||||
query_result: this.latest_query_data,
|
||||
});
|
||||
}
|
||||
} else if (this.latest_query_data_id && maxAge !== 0) {
|
||||
if (!this.queryResult) {
|
||||
this.queryResult = QueryResult.getById(this.latest_query_data_id);
|
||||
}
|
||||
} else if (this.data_source_id) {
|
||||
this.queryResult = QueryResult.get(this.data_source_id, queryText, parameters.getValues(), maxAge, this.id);
|
||||
} else {
|
||||
return new QueryResultError('Please select data source to run this query.');
|
||||
}
|
||||
} else if (this.latest_query_data_id && maxAge !== 0) {
|
||||
if (!this.queryResult) {
|
||||
this.queryResult = QueryResult.getById(this.latest_query_data_id);
|
||||
}
|
||||
} else if (this.data_source_id) {
|
||||
this.queryResult = QueryResult.get(this.data_source_id, queryText, parameters.getValues(), maxAge, this.id);
|
||||
} else {
|
||||
return new QueryResultError('Please select data source to run this query.');
|
||||
this.queryResult = QueryResult.getByQueryId(this.id, parameters.getValues(), maxAge);
|
||||
}
|
||||
|
||||
return this.queryResult;
|
||||
|
||||
Reference in New Issue
Block a user