mirror of
https://github.com/grafana/grafana.git
synced 2025-02-09 23:16:16 -06:00
Query history: Fix search filtering if null value (#26768)
* Fix filtering if null value * Add test coverage
This commit is contained in:
parent
353b3822c1
commit
6a86e66d76
@ -20,7 +20,7 @@ const mock: any = {
|
||||
datasourceId: 'datasource historyId',
|
||||
datasourceName: 'datasource history name',
|
||||
queries: [
|
||||
{ expr: 'query1', refId: '1' },
|
||||
{ expr: 'query1', maxLines: null, refId: '1' },
|
||||
{ expr: 'query2', refId: '2' },
|
||||
],
|
||||
sessionName: '',
|
||||
@ -96,7 +96,7 @@ describe('addToRichHistory', () => {
|
||||
mock.storedHistory,
|
||||
mock.storedHistory[0].datasourceId,
|
||||
mock.storedHistory[0].datasourceName,
|
||||
[{ expr: 'query1', refId: 'A' } as DataQuery, { expr: 'query2', refId: 'B' } as DataQuery],
|
||||
[{ expr: 'query1', maxLines: null, refId: 'A' } as DataQuery, { expr: 'query2', refId: 'B' } as DataQuery],
|
||||
mock.testStarred,
|
||||
mock.testComment,
|
||||
mock.testSessionName
|
||||
@ -110,7 +110,7 @@ describe('addToRichHistory', () => {
|
||||
mock.storedHistory,
|
||||
mock.storedHistory[0].datasourceId,
|
||||
mock.storedHistory[0].datasourceName,
|
||||
[{ expr: 'query1', refId: 'A' } as DataQuery, { expr: 'query2', refId: 'B' } as DataQuery],
|
||||
[{ expr: 'query1', maxLines: null, refId: 'A' } as DataQuery, { expr: 'query2', refId: 'B' } as DataQuery],
|
||||
mock.testStarred,
|
||||
mock.testComment,
|
||||
mock.testSessionName
|
||||
|
@ -330,7 +330,7 @@ export function filterQueriesBySearchFilter(queries: RichHistoryQuery[], searchF
|
||||
const listOfMatchingQueries = query.queries.filter(query =>
|
||||
// Remove fields in which we don't want to be searching
|
||||
Object.values(_.omit(query, ['datasource', 'key', 'refId', 'hide', 'queryType'])).some((value: any) =>
|
||||
value.toString().includes(searchFilter)
|
||||
value?.toString().includes(searchFilter)
|
||||
)
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user