mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Cleanup/remove a couple more unwraps
This commit is contained in:
parent
5e94c879de
commit
50042d79ea
@ -46,8 +46,7 @@ pub async fn circuit_capacity(channels: Arc<PubSub>) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Map circuits to capacities
|
// Map circuits to capacities
|
||||||
let capacities: Vec<Capacity> = {
|
let capacities: Vec<Capacity> = if let Ok(shaped_devices) = SHAPED_DEVICES.read() {
|
||||||
let shaped_devices = SHAPED_DEVICES.read().unwrap();
|
|
||||||
circuits.iter().filter_map(|(circuit_id, accumulator)| {
|
circuits.iter().filter_map(|(circuit_id, accumulator)| {
|
||||||
if let Some(device) = shaped_devices.devices.iter().find(|sd| sd.circuit_id == *circuit_id) {
|
if let Some(device) = shaped_devices.devices.iter().find(|sd| sd.circuit_id == *circuit_id) {
|
||||||
let down_mbps = (accumulator.bytes.down as f64 * 8.0) / 1_000_000.0;
|
let down_mbps = (accumulator.bytes.down as f64 * 8.0) / 1_000_000.0;
|
||||||
@ -65,6 +64,8 @@ pub async fn circuit_capacity(channels: Arc<PubSub>) {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
}).collect()
|
}).collect()
|
||||||
|
} else {
|
||||||
|
Vec::new()
|
||||||
};
|
};
|
||||||
|
|
||||||
let message = json!(
|
let message = json!(
|
||||||
|
@ -29,20 +29,20 @@ impl From<&IpStats> for IpStatsWithPlan {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if !result.circuit_id.is_empty() {
|
if !result.circuit_id.is_empty() {
|
||||||
if let Some(circuit) = SHAPED_DEVICES
|
if let Ok(shaped_devices_reader) = SHAPED_DEVICES.read() {
|
||||||
.read()
|
if let Some(circuit) = shaped_devices_reader
|
||||||
.unwrap()
|
.devices
|
||||||
.devices
|
.iter()
|
||||||
.iter()
|
.find(|sd| sd.circuit_id == result.circuit_id)
|
||||||
.find(|sd| sd.circuit_id == result.circuit_id)
|
{
|
||||||
{
|
let name = if circuit.circuit_name.len() > 20 {
|
||||||
let name = if circuit.circuit_name.len() > 20 {
|
&circuit.circuit_name[0..20]
|
||||||
&circuit.circuit_name[0..20]
|
} else {
|
||||||
} else {
|
&circuit.circuit_name
|
||||||
&circuit.circuit_name
|
};
|
||||||
};
|
result.ip_address = format!("{} ({})", name, result.ip_address);
|
||||||
result.ip_address = format!("{} ({})", name, result.ip_address);
|
result.plan = DownUpOrder::new(circuit.download_max_mbps, circuit.upload_max_mbps);
|
||||||
result.plan = DownUpOrder::new(circuit.download_max_mbps, circuit.upload_max_mbps);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user