Commit 34b8c5bb by David Committed by GitHub

Merge pull request #14278 from grafana/14272-scan-old-logs

only make it possible to scan for older logs if there is at least one…
parents 6cb639ba 27c4db06
...@@ -130,10 +130,15 @@ export function ensureQueries(queries?: DataQuery[]): DataQuery[] { ...@@ -130,10 +130,15 @@ export function ensureQueries(queries?: DataQuery[]): DataQuery[] {
} }
/** /**
* A target is non-empty when it has keys other than refId and key. * A target is non-empty when it has keys (with non-empty values) other than refId and key.
*/ */
export function hasNonEmptyQuery(queries: DataQuery[]): boolean { export function hasNonEmptyQuery(queries: DataQuery[]): boolean {
return queries.some(query => Object.keys(query).length > 2); return queries.some(
query =>
Object.keys(query)
.map(k => query[k])
.filter(v => v).length > 2
);
} }
export function calculateResultsFromQueryTransactions( export function calculateResultsFromQueryTransactions(
......
...@@ -772,6 +772,9 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> { ...@@ -772,6 +772,9 @@ export class Explore extends React.PureComponent<ExploreProps, ExploreState> {
async runQueries(resultType: ResultType, queryOptions: any, resultGetter?: any) { async runQueries(resultType: ResultType, queryOptions: any, resultGetter?: any) {
const queries = [...this.modifiedQueries]; const queries = [...this.modifiedQueries];
if (!hasNonEmptyQuery(queries)) { if (!hasNonEmptyQuery(queries)) {
this.setState({
queryTransactions: [],
});
return; return;
} }
const { datasource } = this.state; const { datasource } = this.state;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment