fix: test reverting changes

This commit is contained in:
mostafaei2002 2024-06-04 16:44:42 +03:30
parent 3589991609
commit c0acc627d3
3 changed files with 6 additions and 9 deletions

View file

@ -525,12 +525,13 @@ impl App {
app.tab = app.state.gupax.tab;
// Set saved Hero mode to runtime.
debug!("Setting runtime_mode & runtime_manual_amount");
app.xvb_api.lock().unwrap().stats_priv.runtime_mode = app.state.xvb.mode.clone().into();
app.xvb_api.lock().unwrap().stats_priv.runtime_manual_amount = match app.state.xvb.amount.parse::<u64>() {
Ok(n) => n,
Err(_) => {
error!("Cannot parse [amount] to u64, defaulting to 0");
0
error!("Cannot parse [amount] to u64, defaulting to 1");
1
}
};

View file

@ -72,18 +72,18 @@ pub(crate) fn calcul_donated_time(
spared_time = minimum_time_for_highest_accessible_round(spared_time, lhr, xvb_chr, shr);
}
let manual_amount = lock!(gui_api_xvb).stats_priv.runtime_manual_amount as u32;
let avg_hr = avg_hr as u32;
if lock!(gui_api_xvb).stats_priv.runtime_mode == RuntimeMode::ManuallyDonante && avg_hr > 0 {
spared_time = XVB_TIME_ALGO * manual_amount / avg_hr;
info!("spared_time = 600 * {manual_amount} / {avg_hr} = {spared_time}")
info!("spared_time = 600 * {manual_amount} / {avg_hr} = {spared_time}");
}
if lock!(gui_api_xvb).stats_priv.runtime_mode == RuntimeMode::ManuallyKeep && avg_hr > 0 {
spared_time = XVB_TIME_ALGO - (XVB_TIME_ALGO * manual_amount / avg_hr);
info!("spared_time = 600 * {manual_amount} / {avg_hr} = {spared_time}")
info!("spared_time = 600 * {manual_amount} / {avg_hr} = {spared_time}");
}
}
if lock!(gui_api_xvb).stats_priv.runtime_mode == RuntimeMode::Hero {
output_console(gui_api_xvb, "Hero mode is enabled for this decision");

View file

@ -401,12 +401,10 @@ impl PubXvbApi {
output.push_str(&buf);
}
let runtime_mode = std::mem::take(&mut gui_api.stats_priv.runtime_mode);
let runtime_manual_amount = std::mem::take(&mut gui_api.stats_priv.runtime_manual_amount);
*gui_api = Self {
output,
stats_priv: XvbPrivStats {
runtime_manual_amount,
runtime_mode,
..pub_api.stats_priv.clone()
},
@ -698,7 +696,6 @@ fn signal_interrupt(
fn reset_data_xvb(pub_api: &Arc<Mutex<PubXvbApi>>, gui_api: &Arc<Mutex<PubXvbApi>>) {
let current_node = mem::take(&mut lock!(pub_api).current_node.clone());
let runtime_mode = mem::take(&mut lock!(gui_api).stats_priv.runtime_mode);
let runtime_manual_amount = mem::take(&mut lock!(gui_api).stats_priv.runtime_manual_amount);
// let output = mem::take(&mut lock!(gui_api).output);
*lock!(pub_api) = PubXvbApi::new();
@ -707,7 +704,6 @@ fn reset_data_xvb(pub_api: &Arc<Mutex<PubXvbApi>>, gui_api: &Arc<Mutex<PubXvbApi
lock!(pub_api).current_node = current_node;
// to not loose the information of runtime hero mode between restart
lock!(gui_api).stats_priv.runtime_mode = runtime_mode;
lock!(gui_api).stats_priv.runtime_manual_amount = runtime_manual_amount;
// message while starting must be preserved.
// lock!(pub_api).output = output;
}