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
12
src/lib.rs
12
src/lib.rs
|
@ -634,7 +634,16 @@ pub fn guess_blockages(
|
||||||
let mut bridge_info: BridgeInfo =
|
let mut bridge_info: BridgeInfo =
|
||||||
bincode::deserialize(&db.get(fingerprint).unwrap().unwrap()).unwrap();
|
bincode::deserialize(&db.get(fingerprint).unwrap().unwrap()).unwrap();
|
||||||
let mut new_blockages = HashSet::<String>::new();
|
let mut new_blockages = HashSet::<String>::new();
|
||||||
let blocked_in = analysis::blocked_in(analyzer, &bridge_info, confidence, get_date());
|
// 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 {
|
for country in blocked_in {
|
||||||
let bridge_country_info = bridge_info.info_by_country.get_mut(&country).unwrap();
|
let bridge_country_info = bridge_info.info_by_country.get_mut(&country).unwrap();
|
||||||
if !bridge_country_info.blocked {
|
if !bridge_country_info.blocked {
|
||||||
|
@ -643,6 +652,7 @@ pub fn guess_blockages(
|
||||||
bridge_country_info.blocked = true;
|
bridge_country_info.blocked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
blockages.insert(fingerprint, new_blockages);
|
blockages.insert(fingerprint, new_blockages);
|
||||||
|
|
||||||
// Commit changes to database
|
// Commit changes to database
|
||||||
|
|
Loading…
Reference in New Issue