fix: peak hours analysis uses all historical data

Remove date range filtering from peak-hours endpoint so the
analysis considers all available data in the database, not just
the last 30 days.
This commit is contained in:
Jose Selesan
2026-08-28 13:31:30 -03:00
parent 0998d64cbb
commit f2c26c266c
4 changed files with 10 additions and 41 deletions

View File

@@ -101,11 +101,8 @@ export function AnalysisPage({ currency }: { currency: string }) {
);
const { data: monthlyLastData } = useMonthlyLast();
const { data: peakHoursData, isLoading: peakHoursLoading } = usePeakHours(
"BELO",
startDateStr,
endDateStr,
);
const { data: peakHoursData, isLoading: peakHoursLoading } =
usePeakHours("BELO");
const chartData = useMemo(() => {
if (!daily) return [];

View File

@@ -122,13 +122,8 @@ export function getHistoricalMinMax(type: string): Promise<HistoricalMinMax> {
return fetcher<HistoricalMinMax>(`/api/quotes/${type}/historical/min-max`);
}
export function getPeakHours(
type: string,
startDate: string,
endDate: string,
): Promise<PeakHoursResponse> {
const params = new URLSearchParams({ startDate, endDate });
return fetcher<PeakHoursResponse>(`/api/quotes/${type}/peak-hours?${params}`);
export function getPeakHours(type: string): Promise<PeakHoursResponse> {
return fetcher<PeakHoursResponse>(`/api/quotes/${type}/peak-hours`);
}
export type MonthlyLast = {

View File

@@ -64,8 +64,8 @@ export const quoteKeys = {
["quotes", type, "daily", startDate, endDate] as const,
historicalMinMax: (type: string) =>
["quotes", type, "historicalMinMax"] as const,
peakHours: (type: string, startDate: string, endDate: string) =>
["quotes", type, "peakHours", startDate, endDate] as const,
peakHours: (type: string) =>
["quotes", type, "peakHours"] as const,
};
export function useQuotes() {
@@ -135,14 +135,10 @@ export function useHistoricalMinMax(type: string) {
});
}
export function usePeakHours(
type: string,
startDate: string,
endDate: string,
) {
export function usePeakHours(type: string) {
return useQuery({
queryKey: quoteKeys.peakHours(type, startDate, endDate),
queryFn: () => getPeakHours(type, startDate, endDate),
queryKey: quoteKeys.peakHours(type),
queryFn: () => getPeakHours(type),
staleTime: 30_000,
});
}