fn parse_or<T: std::str::FromStr>(key: &str, default: T) -> T {
std::env::var(key)
.ok()
.filter(|s| !s.trim().is_empty())
.and_then(|v| v.parse().ok())
.unwrap_or(default)
}
#[derive(Clone, Debug)]
pub struct EntryConfig {
pub anpr_min_votes: u32,
pub entry_retention_days: i64,
}
impl EntryConfig {
pub fn from_env() -> Self {
EntryConfig {
anpr_min_votes: parse_or::<u32>("HELDAR_ANPR_MIN_VOTES", 3).clamp(1, 50),
entry_retention_days: parse_or("HELDAR_ENTRY_RETENTION_DAYS", 365),
}
}
}