fix: blank company charts + competitor GUIDs instead of tickers

Trend charts blank:
- trend_windows uses upsert (1 row per ticker/window), so charts had
  at most 1 data point. Added trend_history table (migration 024) that
  appends every snapshot. New /api/trends/history endpoint serves the
  time series. Frontend now uses useTrendHistory for charts and
  useTrends for the latest summary card.

Competitor GUIDs:
- list_competitors query returned raw company_b_id UUIDs without
  joining companies table. Added LEFT JOIN with CASE to resolve the
  other company's ticker and legal_name. Updated Pydantic model to
  include enriched fields. Frontend fallback changed from truncated
  UUID to ticker/legal_name/Unknown.
This commit is contained in:
Celes Renata
2026-04-17 00:42:55 +00:00
parent f2d8744a4f
commit 7c589353f8
6 changed files with 169 additions and 16 deletions
+9
View File
@@ -236,6 +236,15 @@ export function useTrends(params?: { ticker?: string; window?: string; limit?: n
return useGet<TrendSummary[]>(['trends', params], 'query', path);
}
export function useTrendHistory(params?: { ticker?: string; window?: string; limit?: number }) {
const qs = new URLSearchParams();
if (params?.ticker) qs.set('ticker', params.ticker);
if (params?.window) qs.set('window', params.window);
if (params?.limit) qs.set('limit', String(params.limit ?? 200));
const path = `/api/trends/history${qs.toString() ? '?' + qs : ''}`;
return useGet<TrendSummary[]>(['trend-history', params], 'query', path);
}
export function useTrend(id: string | undefined) {
return useGet<TrendSummary>(['trend', id], 'query', `/api/trends/${id}`, !!id);
}