Version 2.0.0 - Memory Optimization

This commit is contained in:
brotoskyj
2025-11-06 16:47:28 -05:00
parent 954aa24b37
commit 4facceb75b
5 changed files with 9 additions and 11 deletions
+5 -7
View File
@@ -13,9 +13,9 @@ use std::{
env,
fmt::Write,
fs::{self, File},
io::Read,
io::{Read, Seek, SeekFrom},
path::PathBuf,
str::FromStr, sync::mpsc::{Sender, Receiver, channel},
str::FromStr,
};
#[derive(Debug, Deserialize, Serialize)]
@@ -96,9 +96,9 @@ pub fn pull_policy_exec_histories(
let client = build_client(py, &py_self);
let api: Py<PyAny> = py_self;
let cutoff = Local::now().naive_local() - Duration::days(days);
let (tx, rx):(Sender<Group>, Receiver<Group>) = channel();
let mut f = File::open(&writeable_filepath).unwrap();
loop {
let thread_tx = tx.clone();
f.seek(SeekFrom::Start(0)).unwrap();
let execution_histories = history_logging(
py,
&api,
@@ -112,7 +112,6 @@ pub fn pull_policy_exec_histories(
break;
}
let mut seen: HashMap<(String, String, String), Group> = if writeable_filepath.exists() {
let mut f = File::open(&writeable_filepath).unwrap();
let mut contents = String::new();
f.read_to_string(&mut contents).unwrap();
let existing_data: ApiResponse =
@@ -179,8 +178,7 @@ pub fn pull_policy_exec_histories(
)
{
let date_diff = Local::now().naive_local().date() - last_date;
let percentage_diff =
(days - date_diff.num_days()) as f64 / days as f64 * 100.0;
let percentage_diff = (days - date_diff.num_days()) as f64 / days as f64 * 100.0;
progress_bar.set_position(percentage_diff.round() as u64);
progress_bar.set_message("Total Percent Complete");
}