From e66323b303f076700e877d228afbdc4e4e61506c Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Thu, 16 Nov 2023 22:54:32 -0700 Subject: [PATCH] fix issues --- .../src/message_handler.rs | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/rust/libraries/acars_connection_manager/src/message_handler.rs b/rust/libraries/acars_connection_manager/src/message_handler.rs index 06fb47ab..97012f5f 100644 --- a/rust/libraries/acars_connection_manager/src/message_handler.rs +++ b/rust/libraries/acars_connection_manager/src/message_handler.rs @@ -87,7 +87,7 @@ impl MessageHandlerConfig { let stats_total_messages_context: Arc> = Arc::clone(&total_messages_processed); let stats_total_messages_since_last_context: Arc> = Arc::clone(&total_messages_since_last); - let stats_frequency_context: Option(Arc>>) = if self.stats_verbose + let stats_frequency_context: Option>>> = if self.stats_verbose { Some(Arc::clone(&all_frequencies_logged)) } else { @@ -318,7 +318,7 @@ impl MessageHandlerConfig { pub async fn print_stats( total_all_time: Arc>, total_since_last: Arc>, - frequencies: Option(Arc>>), + frequencies: Option>>>, stats_every: u64, queue_type: &str, ) { @@ -335,21 +335,16 @@ pub async fn print_stats( // now print the frequencies, and show each as a percentage of the total_all_time - match frequencies { - None => {} - Some(frequencies) => { - // now print the frequencies, and show each as a percentage of the total_all_time - for freq in frequencies.lock().await.iter_mut() { - let percentage: f64 = - (freq.count as f64 / total_all_time_locked as f64) * 100.0; - output.push_str( - format!( - "{} {}: {}/{} ({:.2}%)\n", - queue_type, freq.freq, freq.count, total_all_time_locked, percentage - ) - .as_str(), - ); - } + if let Some(f) = &frequencies { + for freq in f.lock().await.iter_mut() { + let percentage: f64 = (freq.count as f64 / total_all_time_locked as f64) * 100.0; + output.push_str( + format!( + "{} {}: {}/{} ({:.2}%)\n", + queue_type, freq.freq, freq.count, total_all_time_locked, percentage + ) + .as_str(), + ); } }