Make stats endpoint respect selected time window instead of hardcoded last hour
P99 latency and active count now use the same from/to parameters as the timeseries sparklines, so all stat cards are consistent with the user's selected time range. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,14 +2,23 @@ import { useQuery } from '@tanstack/react-query';
|
||||
import { api } from '../client';
|
||||
import type { SearchRequest } from '../schema';
|
||||
|
||||
export function useExecutionStats() {
|
||||
export function useExecutionStats(timeFrom: string | undefined, timeTo: string | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['executions', 'stats'],
|
||||
queryKey: ['executions', 'stats', timeFrom, timeTo],
|
||||
queryFn: async () => {
|
||||
const { data, error } = await api.GET('/search/stats');
|
||||
const { data, error } = await api.GET('/search/stats', {
|
||||
params: {
|
||||
query: {
|
||||
from: timeFrom!,
|
||||
to: timeTo || undefined,
|
||||
},
|
||||
},
|
||||
});
|
||||
if (error) throw new Error('Failed to load stats');
|
||||
return data!;
|
||||
},
|
||||
enabled: !!timeFrom,
|
||||
placeholderData: (prev) => prev,
|
||||
refetchInterval: 10_000,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user