feat(sources): replace WatcherGuru with CNBC Business
Add the CNBC Business RSS source, switch supported-source wiring and reporting, and migrate existing WatcherGuru rows to disabled historical status without rewriting references. Refs #23 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -149,7 +149,7 @@ func (r *Repository) ListSources() ([]Source, error) {
|
||||
func (r *Repository) GetSourceByType(sourceType string) (*Source, error) {
|
||||
s := &Source{}
|
||||
err := r.db.QueryRow(`
|
||||
SELECT id, name, type, enabled, created_at, article_limit, source_key FROM sources WHERE type=$1 AND source_key IN ('yahoo_finance','bloomberg','watcher_guru')`, sourceType,
|
||||
SELECT id, name, type, enabled, created_at, article_limit, source_key FROM sources WHERE type=$1 AND source_key IN ('yahoo_finance','bloomberg','cnbc_business')`, sourceType,
|
||||
).Scan(&s.ID, &s.Name, &s.Type, &s.Enabled, &s.CreatedAt, &s.ArticleLimit, &s.SourceKey)
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, nil
|
||||
|
||||
@ -3,12 +3,13 @@ package models
|
||||
const (
|
||||
SourceYahooFinance = "yahoo_finance"
|
||||
SourceBloomberg = "bloomberg"
|
||||
SourceWatcherGuru = "watcher_guru"
|
||||
SourceWatcherGuru = "watcher_guru" // Historical identity; no longer executable.
|
||||
SourceCNBCBusiness = "cnbc_business"
|
||||
)
|
||||
|
||||
func SupportedSourceKey(key string) bool {
|
||||
switch key {
|
||||
case SourceYahooFinance, SourceBloomberg, SourceWatcherGuru:
|
||||
case SourceYahooFinance, SourceBloomberg, SourceCNBCBusiness:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
@ -22,3 +22,18 @@ func TestSourceSupportUsesOnlyCanonicalKeyAndPersistedEnabled(t *testing.T) {
|
||||
t.Fatal("disabled target support/operational mismatch")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCNBCReplacesWatcherGuruWithoutAliasingHistoricalIdentity(t *testing.T) {
|
||||
cnbc, watcher := SourceCNBCBusiness, SourceWatcherGuru
|
||||
sources := []Source{{ID: "new-cnbc", SourceKey: &cnbc, Enabled: true, ArticleLimit: 37}, {ID: "old-watcher", SourceKey: &watcher, Enabled: true, ArticleLimit: 64}}
|
||||
if !sources[0].Supported() || sources[1].Supported() || sources[1].Operational() {
|
||||
t.Fatal("retired WatcherGuru remains executable or CNBC unsupported")
|
||||
}
|
||||
operational := OperationalSources(sources)
|
||||
if len(operational) != 1 || operational[0].ID != "new-cnbc" || operational[0].ArticleLimit != 37 {
|
||||
t.Fatalf("operational=%+v", operational)
|
||||
}
|
||||
if *sources[1].SourceKey != "watcher_guru" || sources[1].ArticleLimit != 64 {
|
||||
t.Fatal("historical identity or cap mutated")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user