butcher/trend_setter: tweak algorithm to make min_after_mentions depend on period
This commit is contained in:
parent
c567cb62e9
commit
57da2139c1
|
@ -15,7 +15,7 @@ use cave::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(debug))]
|
#[cfg(not(debug))]
|
||||||
const MIN_INTERVAL: Duration = Duration::from_secs(10);
|
const MIN_INTERVAL: Duration = Duration::from_secs(30);
|
||||||
#[cfg(debug)]
|
#[cfg(debug)]
|
||||||
const MIN_INTERVAL: Duration = Duration::from_secs(5);
|
const MIN_INTERVAL: Duration = Duration::from_secs(5);
|
||||||
|
|
||||||
|
@ -157,8 +157,8 @@ async fn run(
|
||||||
|
|
||||||
let old_tags = old_tags.into_iter().collect::<HashSet<String>>();
|
let old_tags = old_tags.into_iter().collect::<HashSet<String>>();
|
||||||
let mut keep = TREND_POOL_SIZE.min(scores.len());
|
let mut keep = TREND_POOL_SIZE.min(scores.len());
|
||||||
// shrink sorted set of tags as long as score is 0
|
// shrink sorted set of tags as long as score is less than 1
|
||||||
while keep > 0 && scores[keep - 1].0 <= 0. {
|
while keep > 0 && scores[keep - 1].0 < 1.0 {
|
||||||
keep -= 1;
|
keep -= 1;
|
||||||
}
|
}
|
||||||
let remove = scores[keep..].iter()
|
let remove = scores[keep..].iter()
|
||||||
|
|
|
@ -64,7 +64,7 @@ async fn main() {
|
||||||
|
|
||||||
let client = Arc::new(
|
let client = Arc::new(
|
||||||
reqwest::Client::builder()
|
reqwest::Client::builder()
|
||||||
.timeout(Duration::from_secs(5))
|
.timeout(Duration::from_secs(10))
|
||||||
.user_agent(concat!(
|
.user_agent(concat!(
|
||||||
env!("CARGO_PKG_NAME"),
|
env!("CARGO_PKG_NAME"),
|
||||||
"/",
|
"/",
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
use crate::PERIOD_COMPARE_WINDOW;
|
use crate::PERIOD_COMPARE_WINDOW;
|
||||||
|
|
||||||
const MIN_AFTER_MENTIONS: usize = 5;
|
const MIN_AFTER_MENTIONS: &[(u64, usize)] = &[
|
||||||
|
(4, 7),
|
||||||
|
(24, 17),
|
||||||
|
(168, 57)
|
||||||
|
];
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TrendTag {
|
pub struct TrendTag {
|
||||||
|
@ -53,9 +57,11 @@ impl TrendTag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if after_mentions < MIN_AFTER_MENTIONS {
|
for (min_period, min_after_mentions) in MIN_AFTER_MENTIONS {
|
||||||
|
if period >= *min_period && after_mentions < *min_after_mentions {
|
||||||
return 0.;
|
return 0.;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let before = if before_hours > 0 && before_mentions > 0 {
|
let before = if before_hours > 0 && before_mentions > 0 {
|
||||||
(before_mentions as f64) / (before_hours as f64)
|
(before_mentions as f64) / (before_hours as f64)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user