fix: move cutoffTs declaration before its use in filtered
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/build-3 Pipeline was successful
ci/woodpecker/push/build-2 Pipeline was successful
ci/woodpecker/push/build-1 Pipeline was successful
ci/woodpecker/push/finalize Pipeline was successful
Build and Push / lint-and-test (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.adapters.broker_adapter name:broker-adapter]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.aggregation.worker name:aggregation]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.extractor.worker name:extractor]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.ingestion.worker name:ingestion]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.lake_publisher.worker name:lake-publisher]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.parser.worker name:parser]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.recommendation.worker name:recommendation]) (push) Has been cancelled
Build and Push / build-services (map[cmd:python -m services.scheduler.app name:scheduler]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.api.app:app --host 0.0.0.0 --port 8000 name:query-api]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.risk.app:app --host 0.0.0.0 --port 8000 name:risk]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.symbol_registry.app:app --host 0.0.0.0 --port 8000 name:symbol-registry]) (push) Has been cancelled
Build and Push / build-services (map[cmd:uvicorn services.trading.app:app --host 0.0.0.0 --port 8000 name:trading-engine]) (push) Has been cancelled
Build and Push / build-dashboard (push) Has been cancelled
Build and Push / build-superset (push) Has been cancelled
Build and Push / integration-test (push) Has been cancelled
Build and Push / beta-gate (push) Has been cancelled

Variable was used before declaration (temporal dead zone error).
Moved windowHours/hoursBack/cutoffTs above the filtered const that
references cutoffTs.
This commit is contained in:
Celes Renata
2026-04-29 17:08:36 +00:00
parent 531e33b0ce
commit 951b733ac3
+11 -11
View File
@@ -590,17 +590,7 @@ function TrendTooltip({ active, payload, label }: Record<string, unknown>) {
function TrendHistoryChart({ trends, latestTrends, ticker, marketPrices }: { trends: TrendSummary[]; latestTrends: TrendSummary[]; ticker: string; marketPrices: MarketPrice[] }) { function TrendHistoryChart({ trends, latestTrends, ticker, marketPrices }: { trends: TrendSummary[]; latestTrends: TrendSummary[]; ticker: string; marketPrices: MarketPrice[] }) {
const [selectedWindow, setSelectedWindow] = useState('7d'); const [selectedWindow, setSelectedWindow] = useState('7d');
// Use history data for charts — filter to selected window and time range // Determine the time range for the selected window to filter data
const filtered = (trends ?? [])
.filter((t) => t.entity_id === ticker && t.window === selectedWindow && new Date(t.generated_at).getTime() >= cutoffTs)
.sort((a, b) => new Date(a.generated_at).getTime() - new Date(b.generated_at).getTime());
// Build a price lookup — match by closest timestamp to each trend point
const sortedPrices = [...(marketPrices ?? [])]
.filter((p) => p.bar_timestamp != null && p.close != null)
.sort((a, b) => a.bar_timestamp - b.bar_timestamp);
// Determine the time range for the selected window to filter prices
const windowHours: Record<string, number> = { const windowHours: Record<string, number> = {
intraday: 12, intraday: 12,
'1d': 24, '1d': 24,
@@ -611,6 +601,16 @@ function TrendHistoryChart({ trends, latestTrends, ticker, marketPrices }: { tre
const hoursBack = windowHours[selectedWindow] ?? 7 * 24; const hoursBack = windowHours[selectedWindow] ?? 7 * 24;
const cutoffTs = Date.now() - hoursBack * 3600_000; const cutoffTs = Date.now() - hoursBack * 3600_000;
// Use history data for charts — filter to selected window and time range
const filtered = (trends ?? [])
.filter((t) => t.entity_id === ticker && t.window === selectedWindow && new Date(t.generated_at).getTime() >= cutoffTs)
.sort((a, b) => new Date(a.generated_at).getTime() - new Date(b.generated_at).getTime());
// Build a price lookup — match by closest timestamp to each trend point
const sortedPrices = [...(marketPrices ?? [])]
.filter((p) => p.bar_timestamp != null && p.close != null)
.sort((a, b) => a.bar_timestamp - b.bar_timestamp);
// Filter prices to the selected window's time range // Filter prices to the selected window's time range
const windowPrices = sortedPrices.filter((p) => p.bar_timestamp >= cutoffTs); const windowPrices = sortedPrices.filter((p) => p.bar_timestamp >= cutoffTs);