Pass date for analysis, compute age correctly

This commit is contained in:
Vecna 2024-04-15 15:21:35 -04:00
parent 1a8b64080d
commit 45e71f32e8
2 changed files with 5 additions and 4 deletions

View File

@ -1,4 +1,4 @@
use crate::{get_date, BridgeInfo, BridgeInfoType};
use crate::{BridgeInfo, BridgeInfoType};
use lox_library::proto::{level_up::LEVEL_INTERVAL, trust_promotion::UNTRUSTED_INTERVAL};
use nalgebra::DVector;
use statrs::distribution::{Continuous, MultivariateNormal};
@ -50,11 +50,12 @@ pub fn blocked_in(
analyzer: &dyn Analyzer,
bridge_info: &BridgeInfo,
confidence: f64,
date: u32,
) -> HashSet<String> {
// TODO: Re-evaluate past days if we have backdated reports
let mut blocked_in = HashSet::<String>::new();
let today = get_date();
let age = bridge_info.first_seen - today;
let today = date;
let age = today - bridge_info.first_seen;
for (country, info) in &bridge_info.info_by_country {
if info.blocked {
// Assume bridges never become unblocked

View File

@ -583,7 +583,7 @@ pub fn guess_blockages(
let mut bridge_info: BridgeInfo =
bincode::deserialize(&db.get(fingerprint).unwrap().unwrap()).unwrap();
let mut new_blockages = HashSet::<String>::new();
let blocked_in = analysis::blocked_in(analyzer, &bridge_info, confidence);
let blocked_in = analysis::blocked_in(analyzer, &bridge_info, confidence, get_date());
for country in blocked_in {
let bridge_country_info = bridge_info.info_by_country.get_mut(&country).unwrap();
if !bridge_country_info.blocked {