Re-evaluate past days in case we got new reports since last evaluation
It would be better to track which bridges got new reports and only re-evaluate those.
This commit is contained in:
parent
31b27a291a
commit
ec4dc5ca29
24
src/lib.rs
24
src/lib.rs
|
@ -634,13 +634,23 @@ 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, 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 {
|
||||
new_blockages.insert(country.to_string());
|
||||
// Mark bridge as blocked when db gets updated
|
||||
bridge_country_info.blocked = true;
|
||||
// Re-evaluate the last MAX_BACKDATE + 1 days in case we received new
|
||||
// reports for those days. For efficiency, we could instead keep track
|
||||
// of which bridges received new reports and only re-evaluate those.
|
||||
for i in 0..MAX_BACKDATE + 1 {
|
||||
let blocked_in = analysis::blocked_in(
|
||||
analyzer,
|
||||
&bridge_info,
|
||||
confidence,
|
||||
get_date() - MAX_BACKDATE - 1 + i,
|
||||
);
|
||||
for country in blocked_in {
|
||||
let bridge_country_info = bridge_info.info_by_country.get_mut(&country).unwrap();
|
||||
if !bridge_country_info.blocked {
|
||||
new_blockages.insert(country.to_string());
|
||||
// Mark bridge as blocked when db gets updated
|
||||
bridge_country_info.blocked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
blockages.insert(fingerprint, new_blockages);
|
||||
|
|
Loading…
Reference in New Issue