fix: news articles showing 1970 dates when published_at is null
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

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.
This commit is contained in:
Viktor Barzin 2026-02-23 22:48:16 +00:00
parent 9f86aaf540
commit 4df7c67c13
No known key found for this signature in database
GPG key ID: 0EB088298288D958
2 changed files with 5 additions and 3 deletions

View file

@ -8,7 +8,7 @@ interface Article {
title: string; title: string;
source: string; source: string;
url: string; url: string;
published_at: string; published_at: string | null;
ticker: string; ticker: string;
sentiment_score: number; sentiment_score: number;
confidence: number; confidence: number;
@ -105,7 +105,9 @@ export default function NewsFeed() {
<span>{article.source}</span> <span>{article.source}</span>
<span>|</span> <span>|</span>
<span> <span>
{new Date(article.published_at).toLocaleString()} {article.published_at
? new Date(article.published_at).toLocaleString()
: 'Date unknown'}
</span> </span>
{article.ticker && ( {article.ticker && (
<> <>

View file

@ -73,7 +73,7 @@ async def list_news(
"published_at": ( "published_at": (
article.published_at.isoformat() article.published_at.isoformat()
if article.published_at if article.published_at
else None else article.fetched_at.isoformat()
), ),
"fetched_at": article.fetched_at.isoformat(), "fetched_at": article.fetched_at.isoformat(),
"ticker": sentiment.ticker, "ticker": sentiment.ticker,