From 1e3cb6282270ea7df8ac6823493da2c935f1d16b Mon Sep 17 00:00:00 2001 From: Vecna Date: Tue, 20 May 2025 21:04:44 -0400 Subject: [PATCH] Preempt possible errors when looking at historical data --- src/analysis.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/analysis.rs b/src/analysis.rs index 7a06a09..2c3885f 100644 --- a/src/analysis.rs +++ b/src/analysis.rs @@ -64,7 +64,14 @@ pub fn blocked_in( let mut blocked_in = HashSet::::new(); let today = date; 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::::new(); + } + + // (The part above prevents potential errors here.) let age = today - info.first_seen; + if info.blocked { // Assume bridges never become unblocked blocked_in.insert(country.to_string());