mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-07 04:50:57 +08:00
fix: news seen map eviction strategy — keep half instead of clearing all
Previously when the seen map exceeded 1000 entries, ALL entries were deleted, losing dedup state and causing re-notifications. Now evicts ~half the entries, preserving recent URLs for dedup continuity.
This commit is contained in:
@@ -105,7 +105,15 @@ func (b *Brain) scanNews(seen map[string]bool) {
|
||||
emoji, d.Title, d.Source, sentiment))
|
||||
}
|
||||
|
||||
if len(seen) > 1000 { for k := range seen { delete(seen, k) } }
|
||||
// Evict ~half when seen map gets large (keep recent half to avoid re-notifying)
|
||||
if len(seen) > 1000 {
|
||||
i, half := 0, len(seen)/2
|
||||
for k := range seen {
|
||||
if i >= half { break }
|
||||
delete(seen, k)
|
||||
i++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Brain) StartMarketBriefs(hours []int) {
|
||||
|
||||
Reference in New Issue
Block a user