Skip to content

Commit

Permalink
Reapply "[DNA-10871]: Add query source header for redash queries"
Browse files Browse the repository at this point in the history
This reverts commit a46fff3.
  • Loading branch information
puneet-bdp committed May 21, 2024
1 parent a46fff3 commit 38b9775
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ build_stg:

build_prod:
docker build --network=host -t careem-redash . &&\
docker tag careem-redash 848569320300.dkr.ecr.eu-west-1.amazonaws.com/careem-redash:prod &&\
docker push 848569320300.dkr.ecr.eu-west-1.amazonaws.com/careem-redash:prod &&\
docker tag careem-redash 848569320300.dkr.ecr.eu-west-1.amazonaws.com/careem-redash:stg &&\
docker push 848569320300.dkr.ecr.eu-west-1.amazonaws.com/careem-redash:stg
docker tag careem-redash 848569320300.dkr.ecr.eu-west-1.amazonaws.com/careem-redash:11.0.0 &&\
docker push 848569320300.dkr.ecr.eu-west-1.amazonaws.com/careem-redash:11.0.0 &&\
docker tag careem-redash 848569320300.dkr.ecr.eu-west-1.amazonaws.com/careem-redash:latest &&\
docker push 848569320300.dkr.ecr.eu-west-1.amazonaws.com/careem-redash:latest

build_karl_stg:
docker build -t karllchris/redash-stg . && docker push karllchris/redash-stg
Expand Down
4 changes: 2 additions & 2 deletions client/app/services/query-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,11 @@ class QueryResult {
return `${queryName.replace(/ /g, "_") + moment(this.getUpdatedAt()).format("_YYYY_MM_DD")}.${fileType}`;
}

static getByQueryId(id, parameters, applyAutoLimit, maxAge) {
static getByQueryId(id, parameters, applyAutoLimit, maxAge, fromDashboard = false) {
const queryResult = new QueryResult();

axios
.post(`api/queries/${id}/results`, { id, parameters, apply_auto_limit: applyAutoLimit, max_age: maxAge })
.post(`api/queries/${id}/results`, { id, parameters, apply_auto_limit: applyAutoLimit, max_age: maxAge, from_dashboard: fromDashboard})
.then(response => {
queryResult.update(response);

Expand Down
4 changes: 2 additions & 2 deletions client/app/services/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ export class Query {
return this.queryResult;
}

getQueryResult(maxAge) {
getQueryResult(maxAge, fromDashboard = false) {
const execute = () =>
QueryResult.getByQueryId(this.id, this.getParameters().getExecutionValues(), this.getAutoLimit(), maxAge);
QueryResult.getByQueryId(this.id, this.getParameters().getExecutionValues(), this.getAutoLimit(), maxAge, fromDashboard);
return this.prepareQueryResultExecution(execute, maxAge);
}

Expand Down
2 changes: 1 addition & 1 deletion client/app/services/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class Widget {
maxAge = force ? 0 : undefined;
}

const queryResult = this.getQuery().getQueryResult(maxAge);
const queryResult = this.getQuery().getQueryResult(maxAge, true);
this.queryResult = queryResult;

queryResult
Expand Down
5 changes: 4 additions & 1 deletion redash/handlers/query_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def error_response(message, http_status=400):


def run_query(
query, parameters, data_source, query_id, should_apply_auto_limit, max_age=0
query, parameters, data_source, query_id, should_apply_auto_limit, max_age=0, from_dashboard=False
):
if data_source.paused:
if data_source.pause_reason:
Expand Down Expand Up @@ -123,6 +123,7 @@ def run_query(
if current_user.is_api_user()
else current_user.email,
"query_id": query_id,
"Query_source": "Charts" if from_dashboard else "Query page",
},
)
return serialize_job(job)
Expand Down Expand Up @@ -285,6 +286,7 @@ def post(self, query_id):
"""
params = request.get_json(force=True, silent=True) or {}
parameter_values = params.get("parameters", {})
from_dashboard = params.get("from_dashboard", False)

max_age = params.get("max_age", -1)
# max_age might have the value of None, in which case calling int(None) will fail
Expand All @@ -309,6 +311,7 @@ def post(self, query_id):
query_id,
should_apply_auto_limit,
max_age,
from_dashboard
)
else:
if not query.parameterized.is_safe:
Expand Down

0 comments on commit 38b9775

Please sign in to comment.