in lib/looker.ts [79:116]
export async function runQueryForSurface(
template: string,
filters: any,
startDate?: string | null,
endDate?: string | null,
): Promise<any> {
const element0 = await getDashboardElement0(template);
const origQuery = element0.query as IWriteQuery;
// take the query from the original dashboard
const newQueryBody = structuredClone(origQuery);
delete newQueryBody.client_id; // must be unique per-query
const submission_timestamp_date = getLookerSubmissionTimestampDateFilter(
startDate,
endDate,
);
// override the filters
newQueryBody.filters = Object.assign(
{
[getSurfaceData(template).lookerDateFilterPropertyName]:
submission_timestamp_date,
},
filters,
);
const newQuery = await SDK.ok(SDK.create_query(newQueryBody));
const result = await SDK.ok(
SDK.run_query({
query_id: newQuery.id!,
result_format: "json",
}),
);
return result;
}