diff --git a/pkg/calls/alertconfig.go b/pkg/calls/alertconfig.go index 71fde53..0a8b492 100644 --- a/pkg/calls/alertconfig.go +++ b/pkg/calls/alertconfig.go @@ -30,7 +30,7 @@ func (ac AlertConfig) AddAlertConfig(tg Talkgroup, confBytes []byte) error { return nil } -func (ac AlertConfig) ScaleScore(score trending.Score[Talkgroup], t time.Time, coversOpts ...ruletime.CoversOption) float64 { +func (ac AlertConfig) ApplyAlertRules(score trending.Score[Talkgroup], t time.Time, coversOpts ...ruletime.CoversOption) float64 { s, has := ac[score.ID] if !has { return score.Score diff --git a/pkg/calls/alertconfig_test.go b/pkg/calls/alertconfig_test.go index c971fcb..fe141d9 100644 --- a/pkg/calls/alertconfig_test.go +++ b/pkg/calls/alertconfig_test.go @@ -126,7 +126,7 @@ func TestAlertConfig(t *testing.T) { ID: tc.tg, Score: tc.origScore, } - assert.Equal(t, tc.expectScore, toFixed(ac.ScaleScore(cs, tc.t), 5)) + assert.Equal(t, tc.expectScore, toFixed(ac.ApplyAlertRules(cs, tc.t), 5)) }) } } diff --git a/pkg/calls/talkgroups.go b/pkg/calls/talkgroups.go index 19a1702..b9dba95 100644 --- a/pkg/calls/talkgroups.go +++ b/pkg/calls/talkgroups.go @@ -55,7 +55,7 @@ type tgMap map[Talkgroup]database.GetTalkgroupWithLearnedByPackedIDsRow type TalkgroupCache interface { TG(ctx context.Context, tg Talkgroup) (database.GetTalkgroupWithLearnedByPackedIDsRow, bool) SystemName(ctx context.Context, id int) (string, bool) - ScaleScore(score trending.Score[Talkgroup], t time.Time, coversOpts ...ruletime.CoversOption) float64 + ApplyAlertRules(score trending.Score[Talkgroup], t time.Time, coversOpts ...ruletime.CoversOption) float64 Hint(ctx context.Context, tgs []Talkgroup) error Load(ctx context.Context, tgs []int64) error Invalidate() diff --git a/pkg/gordio/alerting/alerting.go b/pkg/gordio/alerting/alerting.go index 89f3bb9..555c692 100644 --- a/pkg/gordio/alerting/alerting.go +++ b/pkg/gordio/alerting/alerting.go @@ -177,7 +177,7 @@ func (as *alerter) eval(ctx context.Context, now time.Time, testMode bool) ([]Al if s.Score > as.cfg.AlertThreshold || testMode { if old, inCache := as.alertCache[s.ID]; !inCache || now.Sub(old.Timestamp) > as.renotify { - s.Score = as.tgCache.ScaleScore(s, now) + s.Score = as.tgCache.ApplyAlertRules(s, now) a, err := as.makeAlert(ctx, s, origScore) if err != nil { return nil, fmt.Errorf("makeAlert: %w", err)