cave/trend_tag: limit before window to 3 * period

This commit is contained in:
Astro 2022-11-10 03:28:20 +01:00
parent 9e17aef13e
commit 5848c48868

View File

@ -89,16 +89,17 @@ impl TrendTag {
}
let from = until - period;
let not_before = from - 3 * period;
let mut before_mentions = 0;
let mut before_hours = 0;
let mut after_mentions = 0;
for (hour, mentions) in self.by_hour.iter().cloned() {
if hour <= from {
if hour > from {
after_mentions += mentions;
} else if hour > not_before {
before_mentions += mentions;
before_hours += 1;
} else {
after_mentions += mentions;
}
}