feat(sources): retire Yahoo and CNBC feeds (#42)

This commit is contained in:
2026-11-25 02:00:25 +01:00
parent 7a342f240d
commit 0503c2653f
41 changed files with 603 additions and 173 deletions

View File

@ -109,7 +109,7 @@ func run(ctx context.Context) error {
if err = server.EnsureAdmin(repo, cfg); err != nil {
return err
}
feeds := map[string]scraper.Scraper{models.SourceYahooFinance: e2estack.FakeScraper{URL: fakeURL, Client: client}}
feeds := map[string]scraper.Scraper{models.SourceBloomberg: e2estack.FakeScraper{URL: fakeURL, Client: client}}
provider := e2estack.FakeProvider{URL: fakeURL, Client: client}
gin.SetMode(gin.TestMode)
gin.DefaultWriter = io.Discard
@ -226,7 +226,7 @@ func seed(db *sql.DB, fakeURL string) error {
if _, err = tx.Exec(`UPDATE sources SET enabled=false`); err != nil {
return err
}
if _, err = tx.Exec(`UPDATE sources SET enabled=true WHERE source_key='yahoo_finance'`); err != nil {
if _, err = tx.Exec(`UPDATE sources SET enabled=true WHERE source_key='bloomberg'`); err != nil {
return err
}
if _, err = tx.Exec(`INSERT INTO ai_providers(id,name,model,endpoint,is_active) VALUES('00000000-0000-0000-0000-000000001202','ollama','fake-laya',$1,true)`, fakeURL); err != nil {

View File

@ -12,9 +12,7 @@ import (
"github.com/tradarr/backend/internal/indices/openfigi"
"github.com/tradarr/backend/internal/models"
"github.com/tradarr/backend/internal/scraper"
"github.com/tradarr/backend/internal/scraper/cnbcbusiness"
"github.com/tradarr/backend/internal/scraper/quanwenrss"
"github.com/tradarr/backend/internal/scraper/yahoofinance"
"github.com/tradarr/backend/internal/server"
)
@ -53,10 +51,8 @@ func main() {
}
feeds := map[string]scraper.Scraper{
models.SourceBloomberg: quanwenrss.New(models.SourceBloomberg, repo, nil),
models.SourceInvesting: quanwenrss.New(models.SourceInvesting, repo, nil),
models.SourceYahooFinance: yahoofinance.New(),
models.SourceCNBCBusiness: cnbcbusiness.New(),
models.SourceBloomberg: quanwenrss.New(models.SourceBloomberg, repo, nil),
models.SourceInvesting: quanwenrss.New(models.SourceInvesting, repo, nil),
}
app := server.New(repo, cfg, server.Dependencies{SummaryDiagnostics: ai.LogSummaryDiagnostic, CompanyCatalog: catalog, LayaRanker: laya, Feeds: feeds, IndexSearcher: openfigi.New(openfigi.Config{APIKey: cfg.OpenFIGIAPIKey, Timeout: cfg.OpenFIGITimeout}, nil), EnableScheduler: true})

View File

@ -0,0 +1,69 @@
package main
import (
"go/ast"
"go/parser"
"go/token"
"testing"
)
func TestTicket42ProductionCompositionContainsOnlyRSSAdapters(t *testing.T) {
file, err := parser.ParseFile(token.NewFileSet(), "main.go", nil, 0)
if err != nil {
t.Fatal(err)
}
found := false
ast.Inspect(file, func(n ast.Node) bool {
literal, ok := n.(*ast.CompositeLit)
if !ok {
return true
}
typ, ok := literal.Type.(*ast.MapType)
if !ok {
return true
}
value, ok := typ.Value.(*ast.SelectorExpr)
if !ok || value.Sel.Name != "Scraper" {
return true
}
found = true
if len(literal.Elts) != 2 {
t.Error("production must compose exactly two source adapters")
}
keys := map[string]bool{}
for _, element := range literal.Elts {
pair, ok := element.(*ast.KeyValueExpr)
if !ok {
t.Error("unexpected source composition")
continue
}
key, ok := pair.Key.(*ast.SelectorExpr)
if !ok {
t.Error("source must have canonical identity")
continue
}
keys[key.Sel.Name] = true
call, ok := pair.Value.(*ast.CallExpr)
if !ok {
t.Error("source must be RSS adapter")
continue
}
ctor, ok := call.Fun.(*ast.SelectorExpr)
if !ok {
t.Error("source must be RSS adapter")
continue
}
pkg, ok := ctor.X.(*ast.Ident)
if !ok || pkg.Name != "quanwenrss" || ctor.Sel.Name != "New" {
t.Error("non-RSS adapter in production composition")
}
}
if !keys["SourceBloomberg"] || !keys["SourceInvesting"] || keys["SourceYahooFinance"] || keys["SourceCNBCBusiness"] {
t.Error("production source keys do not match RSS-only policy")
}
return true
})
if !found {
t.Fatal("production source composition not found")
}
}