feat(generation): select articles in three passes

This commit is contained in:
2026-11-24 00:38:02 +01:00
parent d22f84529f
commit 8022ee0547
27 changed files with 916 additions and 68 deletions

View File

@ -36,8 +36,9 @@ type scraperRequest struct {
}
type scraperArticle struct {
Title string `json:"title"`
URL string `json:"url"`
Title string `json:"title"`
URL string `json:"url"`
PublishedAt json.RawMessage `json:"published_at"`
}
type scraperResponse struct {
@ -72,7 +73,6 @@ func (b *Bloomberg) ScrapeWithCredentials(ctx context.Context, username, passwor
return nil, fmt.Errorf("bloomberg: %s", result.Error)
}
now := time.Now()
var articles []scraper.Article
for _, a := range result.Articles {
title := strings.TrimSpace(a.Title)
@ -80,12 +80,19 @@ func (b *Bloomberg) ScrapeWithCredentials(ctx context.Context, username, passwor
if title == "" || url == "" {
continue
}
var date *time.Time
var rawDate string
if json.Unmarshal(a.PublishedAt, &rawDate) == nil {
if parsed, err := time.Parse(time.RFC3339Nano, rawDate); err == nil {
date = &parsed
}
}
syms := scraper.DetectSymbols(title, symbols)
articles = append(articles, scraper.Article{
Title: title,
Content: title,
URL: url,
PublishedAt: &now,
PublishedAt: date,
Symbols: syms,
})
}