diff --git a/Cargo.lock b/Cargo.lock index 5a64467..8c6a434 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -220,7 +220,6 @@ dependencies = [ "aquatic_udp_protocol", "blake3", "cfg-if", - "compact_str", "constant_time_eq", "crossbeam-channel", "getrandom", diff --git a/aquatic_udp/Cargo.toml b/aquatic_udp/Cargo.toml index 4a302c0..88bc11b 100644 --- a/aquatic_udp/Cargo.toml +++ b/aquatic_udp/Cargo.toml @@ -30,7 +30,6 @@ aquatic_udp_protocol.workspace = true anyhow = "1" blake3 = "1" cfg-if = "1" -compact_str = { version = "0.7", features = ["serde"] } constant_time_eq = "0.2" crossbeam-channel = "0.5" getrandom = "0.2" diff --git a/aquatic_udp/src/workers/statistics/mod.rs b/aquatic_udp/src/workers/statistics/mod.rs index da9a542..90a730b 100644 --- a/aquatic_udp/src/workers/statistics/mod.rs +++ b/aquatic_udp/src/workers/statistics/mod.rs @@ -7,8 +7,8 @@ use std::time::{Duration, Instant}; use anyhow::Context; use aquatic_common::{IndexMap, PanicSentinel}; use aquatic_udp_protocol::PeerClient; -use compact_str::{CompactString, ToCompactString}; use crossbeam_channel::Receiver; +use num_format::{Locale, ToFormattedString}; use serde::Serialize; use time::format_description::well_known::Rfc2822; use time::OffsetDateTime; @@ -37,7 +37,7 @@ struct TemplateData { ipv6: CollectedStatistics, last_updated: String, peer_update_interval: String, - peer_clients: Vec<(CompactString, usize)>, + peer_clients: Vec<(String, String)>, } pub fn run_statistics_worker( @@ -155,15 +155,22 @@ pub fn run_statistics_worker( if let Some(tt) = opt_tt.as_ref() { let mut peer_clients = if config.statistics.extended { - peer_clients - .iter() - .map(|(peer_client, count)| (peer_client.to_compact_string(), *count)) - .collect() + peer_clients.iter().collect() } else { Vec::new() }; - peer_clients.sort_unstable_by(|a, b| b.1.cmp(&a.1)); + peer_clients.sort_unstable_by(|a, b| b.1.cmp(a.1)); + + let peer_clients = peer_clients + .into_iter() + .map(|(peer_client, count)| { + ( + peer_client.to_string(), + count.to_formatted_string(&Locale::en), + ) + }) + .collect(); let template_data = TemplateData { stylesheet: STYLESHEET_CONTENTS.to_string(),