This commit is contained in:
ponzischeme89
2026-08-16 12:13:51 +12:00
parent bd3732fba5
commit b9374baaf1
47 changed files with 2793 additions and 364 deletions
+15 -4
View File
@@ -3,6 +3,7 @@ package credits
import (
"context"
"sort"
"sync"
"time"
)
@@ -39,6 +40,19 @@ const watchLimit = 500
type TracearrSource struct {
DB Database
Cfg Config
mu sync.RWMutex
}
func (s *TracearrSource) Configure(cfg Config) {
s.mu.Lock()
s.Cfg = NormaliseConfig(cfg)
s.mu.Unlock()
}
func (s *TracearrSource) config() Config {
s.mu.RLock()
defer s.mu.RUnlock()
return NormaliseConfig(s.Cfg)
}
// Candidates is the whole predictive pipeline: read recent demand, group it into per-viewer
@@ -51,10 +65,7 @@ func (s *TracearrSource) Candidates(ctx context.Context) ([]Candidate, error) {
if s == nil || s.DB == nil {
return nil, nil
}
cfg := s.Cfg
if cfg.QueueLimit <= 0 {
cfg = DefaultConfig()
}
cfg := s.config()
now := time.Now().UTC()
// The decay window is the query's window too. Anything older cannot survive