Revert the country selection to something that functions.

This commit is contained in:
Herbert Wolverson 2024-07-29 10:29:20 -05:00
parent c6f351352b
commit 5d33a7ed6b
2 changed files with 4 additions and 4 deletions

View File

@ -91,12 +91,12 @@ fn all_flows_to_transport(boot_time: u64, all_flows_for_asn: Vec<(FlowbeeKey, Fl
.collect::<Vec<_>>() .collect::<Vec<_>>()
} }
pub async fn country_timeline(Path(country_name): Path<String>) -> Json<Vec<FlowTimeline>> { pub async fn country_timeline(Path(iso_code): Path<String>) -> Json<Vec<FlowTimeline>> {
let time_since_boot = time_since_boot().unwrap(); let time_since_boot = time_since_boot().unwrap();
let since_boot = Duration::from(time_since_boot); let since_boot = Duration::from(time_since_boot);
let boot_time = unix_now().unwrap() - since_boot.as_secs(); let boot_time = unix_now().unwrap() - since_boot.as_secs();
let all_flows_for_asn = RECENT_FLOWS.all_flows_for_country(&country_name); let all_flows_for_asn = RECENT_FLOWS.all_flows_for_country(&iso_code);
let flows = all_flows_to_transport(boot_time, all_flows_for_asn); let flows = all_flows_to_transport(boot_time, all_flows_for_asn);

View File

@ -292,13 +292,13 @@ impl TimeBuffer {
.collect() .collect()
} }
pub fn all_flows_for_country(&self, country_name: &str) -> Vec<(FlowbeeKey, FlowbeeLocalData, FlowAnalysis)> { pub fn all_flows_for_country(&self, iso_code: &str) -> Vec<(FlowbeeKey, FlowbeeLocalData, FlowAnalysis)> {
let buffer = self.buffer.lock().unwrap(); let buffer = self.buffer.lock().unwrap();
buffer buffer
.iter() .iter()
.filter(|flow| { .filter(|flow| {
let country = get_asn_name_and_country(flow.data.0.remote_ip.as_ip()); let country = get_asn_name_and_country(flow.data.0.remote_ip.as_ip());
country.name == country_name country.flag == iso_code
}) })
.map(|flow| flow.data.clone()) .map(|flow| flow.data.clone())
.collect() .collect()