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