Preempt possible errors when looking at historical data
This commit is contained in:
parent
05f01c2117
commit
1e3cb62822
|
@ -64,7 +64,14 @@ pub fn blocked_in(
|
||||||
let mut blocked_in = HashSet::<String>::new();
|
let mut blocked_in = HashSet::<String>::new();
|
||||||
let today = date;
|
let today = date;
|
||||||
for (country, info) in &bridge_info.info_by_country {
|
for (country, info) in &bridge_info.info_by_country {
|
||||||
|
// If we haven't seen this bridge yet, return empty set
|
||||||
|
if today < info.first_seen {
|
||||||
|
return HashSet::<String>::new();
|
||||||
|
}
|
||||||
|
|
||||||
|
// (The part above prevents potential errors here.)
|
||||||
let age = today - info.first_seen;
|
let age = today - info.first_seen;
|
||||||
|
|
||||||
if info.blocked {
|
if info.blocked {
|
||||||
// Assume bridges never become unblocked
|
// Assume bridges never become unblocked
|
||||||
blocked_in.insert(country.to_string());
|
blocked_in.insert(country.to_string());
|
||||||
|
|
Loading…
Reference in New Issue