From 4df7c67c1372f89060533d2fc11ed981ad3be222 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Mon, 23 Feb 2026 22:48:16 +0000 Subject: [PATCH] fix: news articles showing 1970 dates when published_at is null Backend falls back to fetched_at when published_at is NULL in the database, so the API always returns a meaningful date. Frontend also handles null defensively to avoid new Date(null) producing Unix epoch 0. --- dashboard/src/pages/NewsFeed.tsx | 6 ++++-- services/api_gateway/routes/news.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dashboard/src/pages/NewsFeed.tsx b/dashboard/src/pages/NewsFeed.tsx index 68178ec..8fa388f 100644 --- a/dashboard/src/pages/NewsFeed.tsx +++ b/dashboard/src/pages/NewsFeed.tsx @@ -8,7 +8,7 @@ interface Article { title: string; source: string; url: string; - published_at: string; + published_at: string | null; ticker: string; sentiment_score: number; confidence: number; @@ -105,7 +105,9 @@ export default function NewsFeed() { {article.source} | - {new Date(article.published_at).toLocaleString()} + {article.published_at + ? new Date(article.published_at).toLocaleString() + : 'Date unknown'} {article.ticker && ( <> diff --git a/services/api_gateway/routes/news.py b/services/api_gateway/routes/news.py index 644bab7..57226a6 100644 --- a/services/api_gateway/routes/news.py +++ b/services/api_gateway/routes/news.py @@ -73,7 +73,7 @@ async def list_news( "published_at": ( article.published_at.isoformat() if article.published_at - else None + else article.fetched_at.isoformat() ), "fetched_at": article.fetched_at.isoformat(), "ticker": sentiment.ticker,