Rename to ApplyAlertRules
This commit is contained in:
parent
36bc28899b
commit
2922db0db9
4 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue