feat(sources): retire Yahoo and CNBC feeds (#42)
This commit is contained in:
@ -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})
|
||||
|
||||
69
backend/cmd/server/source_composition_ticket42_test.go
Normal file
69
backend/cmd/server/source_composition_ticket42_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user