butcher/trend_setter: wiggle algorithm thresholds for less spam

This commit is contained in:
Astro 2023-11-10 23:32:12 +01:00
parent 21db1fc4c9
commit 8d2fcbcb9e
2 changed files with 8 additions and 6 deletions

View File

@ -157,8 +157,8 @@ async fn run(
let old_tags = old_tags.into_iter().collect::<HashSet<String>>();
let mut keep = TREND_POOL_SIZE.min(scores.len());
// shrink sorted set of tags as long as score is less than 1
while keep > 0 && scores[keep - 1].0 < 1.0 {
// shrink sorted set of tags as long as score is 0
while keep > 0 && scores[keep - 1].0 <= 0.0 {
keep -= 1;
}
let remove = scores[keep..].iter()

View File

@ -2,9 +2,9 @@ use std::collections::BTreeSet;
use crate::PERIOD_COMPARE_WINDOW;
const MIN_AFTER_MENTIONS: &[(u64, usize)] = &[
(4, 7),
(4, 9),
(24, 17),
(168, 57)
(168, 37),
];
#[derive(Debug)]
@ -48,9 +48,11 @@ impl TrendTag {
let mut before_hours = 0;
let mut after_mentions = 0;
for (hour, mentions) in self.hour_users.iter().cloned() {
for (hour, mut mentions) in self.hour_users.iter().cloned() {
if hour > from {
after_mentions += mentions;
if mentions > 1 {
after_mentions += mentions;
}
} else if hour > not_before {
before_mentions += mentions;
before_hours += 1;