Don't apply talkgroup weight twice
Also tag ID fields
This commit is contained in:
parent
fb2387c212
commit
65cddbcc0d
2 changed files with 4 additions and 7 deletions
|
@ -169,12 +169,9 @@ func (as *alerter) eval(ctx context.Context, now time.Time, testMode bool) ([]Al
|
||||||
for _, s := range as.scores {
|
for _, s := range as.scores {
|
||||||
origScore := s.Score
|
origScore := s.Score
|
||||||
tgr, err := as.tgCache.TG(ctx, s.ID)
|
tgr, err := as.tgCache.TG(ctx, s.ID)
|
||||||
if err == nil {
|
if err == nil && !tgr.Talkgroup.Alert {
|
||||||
if !tgr.Talkgroup.Alert {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
s.Score *= float64(tgr.Talkgroup.Weight)
|
|
||||||
}
|
|
||||||
|
|
||||||
if s.Score > as.cfg.AlertThreshold || testMode {
|
if s.Score > as.cfg.AlertThreshold || testMode {
|
||||||
if old, inCache := as.alertCache[s.ID]; !inCache || now.Sub(old.Timestamp) > as.renotify {
|
if old, inCache := as.alertCache[s.ID]; !inCache || now.Sub(old.Timestamp) > as.renotify {
|
||||||
|
|
|
@ -13,8 +13,8 @@ type Talkgroup struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ID struct {
|
type ID struct {
|
||||||
System uint32
|
System uint32 `json:"sys"`
|
||||||
Talkgroup uint32
|
Talkgroup uint32 `json:"tg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type IDs []ID
|
type IDs []ID
|
||||||
|
|
Loading…
Reference in a new issue