The execution-related "group" concept actually represents the application name. Rename all Java fields, API parameters, and frontend types from groupName→applicationName and group→application for clarity. - Java records: ExecutionSummary, ExecutionDetail, ExecutionDocument, ExecutionRecord, ProcessorRecord - API params: SearchRequest.group→application, SearchController @RequestParam group→application - Services: IngestionService, DetailService, SearchIndexer, StatsStore - Frontend: schema.d.ts, Dashboard, ExchangeDetail, RouteDetail, executions query hooks Database column names (group_name) and OpenSearch field names are unchanged — only the API-facing Java/TS field names are renamed. RBAC group references (groups table, GroupRepository, GroupsTab) are a separate domain concept and are NOT affected by this change. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
112 lines
3.1 KiB
TypeScript
112 lines
3.1 KiB
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { api } from '../client';
|
|
import type { SearchRequest } from '../types';
|
|
|
|
export function useExecutionStats(
|
|
timeFrom: string | undefined,
|
|
timeTo: string | undefined,
|
|
routeId?: string,
|
|
application?: string,
|
|
) {
|
|
return useQuery({
|
|
queryKey: ['executions', 'stats', timeFrom, timeTo, routeId, application],
|
|
queryFn: async () => {
|
|
const { data, error } = await api.GET('/search/stats', {
|
|
params: {
|
|
query: {
|
|
from: timeFrom!,
|
|
to: timeTo || undefined,
|
|
routeId: routeId || undefined,
|
|
application: application || undefined,
|
|
},
|
|
},
|
|
});
|
|
if (error) throw new Error('Failed to load stats');
|
|
return data!;
|
|
},
|
|
enabled: !!timeFrom,
|
|
placeholderData: (prev) => prev,
|
|
refetchInterval: 10_000,
|
|
});
|
|
}
|
|
|
|
export function useSearchExecutions(filters: SearchRequest, live = false) {
|
|
return useQuery({
|
|
queryKey: ['executions', 'search', filters],
|
|
queryFn: async () => {
|
|
const { data, error } = await api.POST('/search/executions', {
|
|
body: filters,
|
|
});
|
|
if (error) throw new Error('Search failed');
|
|
return data!;
|
|
},
|
|
placeholderData: (prev) => prev,
|
|
refetchInterval: live ? 5_000 : false,
|
|
});
|
|
}
|
|
|
|
export function useStatsTimeseries(
|
|
timeFrom: string | undefined,
|
|
timeTo: string | undefined,
|
|
routeId?: string,
|
|
application?: string,
|
|
) {
|
|
return useQuery({
|
|
queryKey: ['executions', 'timeseries', timeFrom, timeTo, routeId, application],
|
|
queryFn: async () => {
|
|
const { data, error } = await api.GET('/search/stats/timeseries', {
|
|
params: {
|
|
query: {
|
|
from: timeFrom!,
|
|
to: timeTo || undefined,
|
|
buckets: 24,
|
|
routeId: routeId || undefined,
|
|
application: application || undefined,
|
|
},
|
|
},
|
|
});
|
|
if (error) throw new Error('Failed to load timeseries');
|
|
return data!;
|
|
},
|
|
enabled: !!timeFrom,
|
|
placeholderData: (prev) => prev,
|
|
refetchInterval: 30_000,
|
|
});
|
|
}
|
|
|
|
export function useExecutionDetail(executionId: string | null) {
|
|
return useQuery({
|
|
queryKey: ['executions', 'detail', executionId],
|
|
queryFn: async () => {
|
|
const { data, error } = await api.GET('/executions/{executionId}', {
|
|
params: { path: { executionId: executionId! } },
|
|
});
|
|
if (error) throw new Error('Failed to load execution detail');
|
|
return data!;
|
|
},
|
|
enabled: !!executionId,
|
|
});
|
|
}
|
|
|
|
export function useProcessorSnapshot(
|
|
executionId: string | null,
|
|
index: number | null,
|
|
) {
|
|
return useQuery({
|
|
queryKey: ['executions', 'snapshot', executionId, index],
|
|
queryFn: async () => {
|
|
const { data, error } = await api.GET(
|
|
'/executions/{executionId}/processors/{index}/snapshot',
|
|
{
|
|
params: {
|
|
path: { executionId: executionId!, index: index! },
|
|
},
|
|
},
|
|
);
|
|
if (error) throw new Error('Failed to load snapshot');
|
|
return data!;
|
|
},
|
|
enabled: !!executionId && index !== null,
|
|
});
|
|
}
|