[skip travis] minor refactor of conversion fns

This commit is contained in:
ClementTsang 2020-02-05 21:37:49 -05:00
parent a9565d21a3
commit 8782b327b9
2 changed files with 12 additions and 46 deletions

View File

@ -58,41 +58,7 @@ impl From<&CpuPoint> for (f64, f64) {
}
}
pub fn convert_all(app: &App, current_data: &data_farmer::DataCollection) {
let current_time = current_data.current_instant;
// Network
let network_data: ConvertedNetworkData = ConvertedNetworkData::default();
let network_data_rx: Vec<(f64, f64)> = Vec::new();
let network_data_tx: Vec<(f64, f64)> = Vec::new();
let rx_display: String = String::default();
let tx_display: String = String::default();
let total_rx_display: String = String::default();
let total_tx_display: String = String::default();
// Disk
let mut disk_table_data: Vec<Vec<String>> = Vec::new();
// Temp
let temp_sensor_table_data: Vec<Vec<String>> = update_temp_row(app);
// Mem
let mut mem_vector: Vec<(f64, f64)> = Vec::new();
let mut swap_vector: Vec<(f64, f64)> = Vec::new();
let memory_and_swap_labels: (String, String);
// CPU
let mut cpu_vector: Vec<ConvertedCpuData> = Vec::new();
// Process
let mut process_single_list: HashMap<u32, ProcessHarvest> = HashMap::new();
let mut process_grouped_hashmap: HashMap<String, (u32, f64, f64, Vec<u32>)> =
std::collections::HashMap::new();
for (time, data) in &current_data.timed_data_vec {}
}
pub fn update_temp_row(app: &App) -> Vec<Vec<String>> {
pub fn convert_temp_row(app: &App) -> Vec<Vec<String>> {
let mut sensor_vector: Vec<Vec<String>> = Vec::new();
let current_data = &app.data_collection;
@ -117,7 +83,7 @@ pub fn update_temp_row(app: &App) -> Vec<Vec<String>> {
sensor_vector
}
pub fn update_disk_row(current_data: &data_farmer::DataCollection) -> Vec<Vec<String>> {
pub fn convert_disk_row(current_data: &data_farmer::DataCollection) -> Vec<Vec<String>> {
let mut disk_vector: Vec<Vec<String>> = Vec::new();
for (itx, disk) in current_data.disk_harvest.iter().enumerate() {
let io_activity = if current_data.io_labels.len() > itx {
@ -153,7 +119,7 @@ pub fn update_disk_row(current_data: &data_farmer::DataCollection) -> Vec<Vec<St
disk_vector
}
pub fn update_cpu_data_points(
pub fn convert_cpu_data_points(
show_avg_cpu: bool, current_data: &data_farmer::DataCollection,
) -> Vec<ConvertedCpuData> {
let mut cpu_data_vector: Vec<ConvertedCpuData> = Vec::new();
@ -200,7 +166,7 @@ pub fn update_cpu_data_points(
cpu_data_vector
}
pub fn update_mem_data_points(current_data: &data_farmer::DataCollection) -> Vec<(f64, f64)> {
pub fn convert_mem_data_points(current_data: &data_farmer::DataCollection) -> Vec<(f64, f64)> {
let mut result: Vec<(f64, f64)> = Vec::new();
let current_time = current_data.current_instant;
@ -221,7 +187,7 @@ pub fn update_mem_data_points(current_data: &data_farmer::DataCollection) -> Vec
result
}
pub fn update_swap_data_points(current_data: &data_farmer::DataCollection) -> Vec<(f64, f64)> {
pub fn convert_swap_data_points(current_data: &data_farmer::DataCollection) -> Vec<(f64, f64)> {
let mut result: Vec<(f64, f64)> = Vec::new();
let current_time = current_data.current_instant;
@ -242,7 +208,7 @@ pub fn update_swap_data_points(current_data: &data_farmer::DataCollection) -> Ve
result
}
pub fn update_mem_labels(current_data: &data_farmer::DataCollection) -> (String, String) {
pub fn convert_mem_labels(current_data: &data_farmer::DataCollection) -> (String, String) {
let mem_label = if current_data.memory_harvest.mem_total_in_mb == 0 {
"".to_string()
} else {

View File

@ -336,20 +336,20 @@ fn main() -> error::Result<()> {
app.canvas_data.total_tx_display = network_data.total_tx_display;
// Disk
app.canvas_data.disk_data = update_disk_row(&app.data_collection);
app.canvas_data.disk_data = convert_disk_row(&app.data_collection);
// Temperatures
app.canvas_data.temp_sensor_data = update_temp_row(&app);
app.canvas_data.temp_sensor_data = convert_temp_row(&app);
// Memory
app.canvas_data.mem_data = update_mem_data_points(&app.data_collection);
app.canvas_data.swap_data = update_swap_data_points(&app.data_collection);
let memory_and_swap_labels = update_mem_labels(&app.data_collection);
app.canvas_data.mem_data = convert_mem_data_points(&app.data_collection);
app.canvas_data.swap_data = convert_swap_data_points(&app.data_collection);
let memory_and_swap_labels = convert_mem_labels(&app.data_collection);
app.canvas_data.mem_label = memory_and_swap_labels.0;
app.canvas_data.swap_label = memory_and_swap_labels.1;
// CPU
app.canvas_data.cpu_data =
update_cpu_data_points(app.show_average_cpu, &app.data_collection);
convert_cpu_data_points(app.show_average_cpu, &app.data_collection);
// Processes
let (single, grouped) = convert_process_data(&app.data_collection);