mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-15 01:46:00 +08:00
fix: query key is updated (#2894)
This commit is contained in:
parent
a649ced337
commit
148889e198
@ -38,10 +38,6 @@ function QuerySection({
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleRunQuery = (): void => {
|
|
||||||
runQuery();
|
|
||||||
};
|
|
||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{
|
{
|
||||||
label: t('tab_qb'),
|
label: t('tab_qb'),
|
||||||
@ -76,7 +72,7 @@ function QuerySection({
|
|||||||
onChange={handleQueryCategoryChange}
|
onChange={handleQueryCategoryChange}
|
||||||
tabBarExtraContent={
|
tabBarExtraContent={
|
||||||
<span style={{ display: 'flex', gap: '1rem', alignItems: 'center' }}>
|
<span style={{ display: 'flex', gap: '1rem', alignItems: 'center' }}>
|
||||||
<Button type="primary" onClick={handleRunQuery}>
|
<Button type="primary" onClick={runQuery}>
|
||||||
Run Query
|
Run Query
|
||||||
</Button>
|
</Button>
|
||||||
</span>
|
</span>
|
||||||
@ -95,7 +91,7 @@ function QuerySection({
|
|||||||
onChange={handleQueryCategoryChange}
|
onChange={handleQueryCategoryChange}
|
||||||
tabBarExtraContent={
|
tabBarExtraContent={
|
||||||
<span style={{ display: 'flex', gap: '1rem', alignItems: 'center' }}>
|
<span style={{ display: 'flex', gap: '1rem', alignItems: 'center' }}>
|
||||||
<Button type="primary" onClick={handleRunQuery}>
|
<Button type="primary" onClick={runQuery}>
|
||||||
Run Query
|
Run Query
|
||||||
</Button>
|
</Button>
|
||||||
</span>
|
</span>
|
||||||
@ -132,7 +128,7 @@ interface QuerySectionProps {
|
|||||||
queryCategory: EQueryType;
|
queryCategory: EQueryType;
|
||||||
setQueryCategory: (n: EQueryType) => void;
|
setQueryCategory: (n: EQueryType) => void;
|
||||||
alertType: AlertTypes;
|
alertType: AlertTypes;
|
||||||
runQuery: () => void;
|
runQuery: VoidFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default QuerySection;
|
export default QuerySection;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
||||||
|
import { useMemo } from 'react';
|
||||||
import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query';
|
import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query';
|
||||||
|
import { useLocation } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
GetMetricQueryRange,
|
GetMetricQueryRange,
|
||||||
GetQueryResultsProps,
|
GetQueryResultsProps,
|
||||||
@ -10,9 +12,19 @@ import { MetricRangePayloadProps } from 'types/api/metrics/getQueryRange';
|
|||||||
export const useGetQueryRange = (
|
export const useGetQueryRange = (
|
||||||
requestData: GetQueryResultsProps,
|
requestData: GetQueryResultsProps,
|
||||||
options?: UseQueryOptions<SuccessResponse<MetricRangePayloadProps>, Error>,
|
options?: UseQueryOptions<SuccessResponse<MetricRangePayloadProps>, Error>,
|
||||||
): UseQueryResult<SuccessResponse<MetricRangePayloadProps>, Error> =>
|
): UseQueryResult<SuccessResponse<MetricRangePayloadProps>, Error> => {
|
||||||
useQuery<SuccessResponse<MetricRangePayloadProps>, Error>({
|
const { key } = useLocation();
|
||||||
queryKey: [REACT_QUERY_KEY.GET_QUERY_RANGE, requestData],
|
|
||||||
|
const queryKey = useMemo(() => {
|
||||||
|
if (options?.queryKey) {
|
||||||
|
return [...options.queryKey, key];
|
||||||
|
}
|
||||||
|
return [REACT_QUERY_KEY.GET_QUERY_RANGE, key, requestData];
|
||||||
|
}, [key, options?.queryKey, requestData]);
|
||||||
|
|
||||||
|
return useQuery<SuccessResponse<MetricRangePayloadProps>, Error>({
|
||||||
queryFn: async () => GetMetricQueryRange(requestData),
|
queryFn: async () => GetMetricQueryRange(requestData),
|
||||||
...options,
|
...options,
|
||||||
|
queryKey,
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user