Files
TradarrV2/backend/internal/models/source_support.go
Blomios ac17d27f51 feat(sources): enforce supported source allowlist
Assign stable keys to the three supported sources, preserve excluded historical rows, and expose history read-only in admin. Add migration, coverage, and responsive browser spec.

Refs #13

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-21 00:11:26 +01:00

27 lines
658 B
Go

package models
const (
SourceYahooFinance = "yahoo_finance"
SourceBloomberg = "bloomberg"
SourceWatcherGuru = "watcher_guru"
)
func SupportedSourceKey(key string) bool {
switch key {
case SourceYahooFinance, SourceBloomberg, SourceWatcherGuru:
return true
}
return false
}
func (s Source) Supported() bool { return s.SourceKey != nil && SupportedSourceKey(*s.SourceKey) }
func (s Source) Operational() bool { return s.Enabled && s.Supported() }
func OperationalSources(sources []Source) []Source {
result := []Source{}
for _, source := range sources {
if source.Operational() {
result = append(result, source)
}
}
return result
}