Skip to content

Commit

Permalink
Merge branch 'issue-330' of github.com:Altinity/clickhouse-grafana in…
Browse files Browse the repository at this point in the history
…to issue-330
  • Loading branch information
Slach committed Nov 17, 2024
2 parents a10941e + 1a87670 commit a9aa533
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/datasource/sql-query/sql_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export default class SqlQuery {
let intervalMs = SqlQueryHelper.convertInterval(i, this.target.intervalFactor || 1, true);
let adhocCondition: any[] = [];

adhocFilters = this.target.adHocFilters
try {
let ast = scanner.toAST();
let topQueryAST = ast;
Expand Down
4 changes: 2 additions & 2 deletions src/views/QueryEditor/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export function QueryEditor(props: QueryEditorProps<CHDataSource, CHQuery, CHDat
const areAdHocFiltersAvailable = !!adHocFilters.length;

useEffect(() => {
if (adHocFilters.length > 0 && initializedQuery.format === 'logs') {
if (props.app !== 'explore') {
onChange({ ...initializedQuery, adHocFilters: adHocFilters });
}

// eslint-disable-next-line
}, [adHocFilters.length, initializedQuery.format]);
}, [props.app, adHocFilters.length]);

return (
<>
Expand Down
4 changes: 1 addition & 3 deletions src/views/QueryEditor/hooks/useFormattedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ export const useFormattedData = (query: CHQuery, datasource: CHDataSource): [str
try {
if (datasource.options && datasource.templateSrv) {
const queryModel = new SqlQuery(query, datasource.templateSrv, datasource.options);
// @ts-ignore
const adHocFilters = datasource.templateSrv.getAdhocFilters(datasource.name);
const replaced = queryModel.replace(datasource.options, adHocFilters);
const replaced = queryModel.replace(datasource.options, query.adHocFilters);
setFormattedData(replaced);
setError(null);
}
Expand Down

0 comments on commit a9aa533

Please sign in to comment.