Spam filter performance and accuracy improvements (part 5)
This commit is contained in:
@@ -363,14 +363,14 @@ impl ClusterRole {
|
||||
matches!(self, ClusterRole::Enabled | ClusterRole::Sharded { .. })
|
||||
}
|
||||
|
||||
pub fn is_enabled_for_account(&self, account_id: u32) -> bool {
|
||||
pub fn is_enabled_for_integer(&self, value: u32) -> bool {
|
||||
match self {
|
||||
ClusterRole::Enabled => true,
|
||||
ClusterRole::Disabled => false,
|
||||
ClusterRole::Sharded {
|
||||
shard_id,
|
||||
total_shards,
|
||||
} => (account_id % total_shards) == *shard_id,
|
||||
} => (value % total_shards) == *shard_id,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ pub struct ClassifierConfig {
|
||||
pub auto_learn_reply_ham: bool,
|
||||
pub auto_learn_card_is_ham: bool,
|
||||
pub hold_samples_for: u64,
|
||||
pub train_frequency: Option<Duration>,
|
||||
pub train_frequency: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -486,7 +486,8 @@ impl ClassifierConfig {
|
||||
"spam-filter.classifier.training.frequency",
|
||||
"12h",
|
||||
)
|
||||
.unwrap_or(Some(Duration::from_secs(12 * 60 * 60))),
|
||||
.unwrap_or(Some(Duration::from_secs(12 * 60 * 60)))
|
||||
.map(|d| d.as_secs()),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ use store::{
|
||||
DirectoryClass, QueueClass, ValueClass, key::DeserializeBigEndian, now,
|
||||
},
|
||||
};
|
||||
use trc::AddContext;
|
||||
use trc::{AddContext, SpamEvent};
|
||||
use types::{
|
||||
blob::{BlobClass, BlobId},
|
||||
blob_hash::BlobHash,
|
||||
@@ -1071,10 +1071,16 @@ impl Server {
|
||||
last_trained_at: model.last_trained_at,
|
||||
}));
|
||||
} else {
|
||||
let todo = "log insufficient samples, keep existing model";
|
||||
trc::event!(
|
||||
Spam(SpamEvent::ModelNotReady),
|
||||
Details = vec![
|
||||
trc::Value::from(model.ham_count),
|
||||
trc::Value::from(model.spam_count)
|
||||
],
|
||||
);
|
||||
}
|
||||
} else {
|
||||
let todo = "log missing model, keep existing one";
|
||||
trc::event!(Spam(SpamEvent::ModelNotFound));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user