mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 04:55:55 +08:00
fix: where clause filter (#2800)
This commit is contained in:
parent
eb1c5c4565
commit
bc5862646d
@ -44,7 +44,7 @@ function QueryBuilderSearch({
|
||||
searchKey,
|
||||
} = useAutoComplete(query);
|
||||
|
||||
const { keys } = useFetchKeysAndValues(searchValue, query, searchKey);
|
||||
const { sourceKeys } = useFetchKeysAndValues(searchValue, query, searchKey);
|
||||
|
||||
const onTagRender = ({
|
||||
value,
|
||||
@ -108,7 +108,7 @@ function QueryBuilderSearch({
|
||||
const initialTagFilters: TagFilter = { items: [], op: 'AND' };
|
||||
initialTagFilters.items = tags.map((tag) => {
|
||||
const { tagKey, tagOperator, tagValue } = getTagToken(tag);
|
||||
const filterAttribute = (keys || []).find(
|
||||
const filterAttribute = sourceKeys.find(
|
||||
(key) => key.key === getRemovePrefixFromKey(tagKey),
|
||||
);
|
||||
return {
|
||||
@ -127,8 +127,8 @@ function QueryBuilderSearch({
|
||||
};
|
||||
});
|
||||
onChange(initialTagFilters);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [keys, tags]);
|
||||
/* eslint-disable react-hooks/exhaustive-deps */
|
||||
}, [sourceKeys, tags]);
|
||||
|
||||
return (
|
||||
<Select
|
||||
|
@ -6,6 +6,7 @@ import {
|
||||
getTagToken,
|
||||
isInNInOperator,
|
||||
} from 'container/QueryBuilder/filters/QueryBuilderSearch/utils';
|
||||
import { isEqual, uniqWith } from 'lodash-es';
|
||||
import debounce from 'lodash-es/debounce';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useQuery } from 'react-query';
|
||||
@ -18,6 +19,7 @@ type IuseFetchKeysAndValues = {
|
||||
keys: BaseAutocompleteData[];
|
||||
results: string[];
|
||||
isFetching: boolean;
|
||||
sourceKeys: BaseAutocompleteData[];
|
||||
};
|
||||
|
||||
/**
|
||||
@ -33,6 +35,7 @@ export const useFetchKeysAndValues = (
|
||||
searchKey: string,
|
||||
): IuseFetchKeysAndValues => {
|
||||
const [keys, setKeys] = useState<BaseAutocompleteData[]>([]);
|
||||
const [sourceKeys, setSourceKeys] = useState<BaseAutocompleteData[]>([]);
|
||||
const [results, setResults] = useState<string[]>([]);
|
||||
|
||||
const searchParams = useMemo(
|
||||
@ -138,7 +141,10 @@ export const useFetchKeysAndValues = (
|
||||
// update the fetched keys when the fetch status changes
|
||||
useEffect(() => {
|
||||
if (status === 'success' && data?.payload?.attributeKeys) {
|
||||
setKeys(data?.payload.attributeKeys);
|
||||
setKeys(data.payload.attributeKeys);
|
||||
setSourceKeys((prevState) =>
|
||||
uniqWith([...(data.payload.attributeKeys ?? []), ...prevState], isEqual),
|
||||
);
|
||||
} else {
|
||||
setKeys([]);
|
||||
}
|
||||
@ -148,5 +154,6 @@ export const useFetchKeysAndValues = (
|
||||
keys,
|
||||
results,
|
||||
isFetching,
|
||||
sourceKeys,
|
||||
};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user