diff --git a/src/previews/header.rs b/src/previews/header.rs index a603bc3..193087a 100644 --- a/src/previews/header.rs +++ b/src/previews/header.rs @@ -3,6 +3,7 @@ pub struct Headers {} impl Headers { // will be deprecated by next version + #[deprecated] pub fn get_recipe_table_sgp_24022025() -> Vec<&'static str> { [ "Name", @@ -128,6 +129,7 @@ impl Headers { .to_vec() } + #[deprecated] pub fn get_recipe_table_dubai_16052025() -> Vec<&'static str> { [ "Name", diff --git a/src/recipe_functions/import.rs b/src/recipe_functions/import.rs index effff2b..d36a053 100644 --- a/src/recipe_functions/import.rs +++ b/src/recipe_functions/import.rs @@ -1,6 +1,7 @@ use std::str::FromStr; use log::{debug, info}; +use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator}; use serde_json::{Number, Value}; use super::common::*; @@ -339,7 +340,7 @@ pub fn import_menu(main_version: usize, country_name: &str, into_version: usize) } pub fn generate_recipe_sheet_table(country_name: &str, into_version: usize) { - let mut latest_recipe = + let latest_recipe = create_recipe_model_from_file(create_recipe_path(country_name, into_version)); let mut recipe_table = Table::new(); @@ -400,7 +401,24 @@ pub fn generate_recipe_sheet_table(country_name: &str, into_version: usize) { } } - latest_recipe.clone().Recipe01.iter_mut().for_each(|rpl| { + // FIX: case sub menu is ignored + let sub_menu_fetched: Vec> = latest_recipe + .Recipe01 + .clone() + .par_iter_mut() + .filter_map(|x| { + if x.SubMenu.clone().is_some_and(|xs| !xs.is_empty()) { + Some(x.SubMenu.clone().unwrap()) + } else { + None + } + }) + .collect(); + let mut submenus = sub_menu_fetched.concat(); + let mut recipe_iter = latest_recipe.clone().Recipe01; + recipe_iter.append(&mut submenus); + + recipe_iter.iter_mut().for_each(|rpl| { let binding = rpl.clone(); let mat_list = binding .recipes @@ -452,19 +470,6 @@ pub fn generate_recipe_sheet_table(country_name: &str, into_version: usize) { .enumerate() .for_each(|(header_idx, header)| { if header_idx > 1 && header.eq(¤t_material.to_string()) { - // search mat settings for further info - - // if rpl.productCode.clone().ends_with("0090") { - // debug!( - // "MAT [{}]: {} --> {} = pow:{:?},sy:{:?}", - // rpl.productCode.clone(), - // header_idx, - // repl.materialPathId.clone(), - // repl.powderGram, - // repl.syrupGram - // ); - // } - let mat_setting = latest_recipe .search_material_settings(current_material.to_string()); @@ -488,29 +493,10 @@ pub fn generate_recipe_sheet_table(country_name: &str, into_version: usize) { } } recipe::MaterialType::Syrup => { - // debug - // if rpl.productCode.clone().ends_with("0090") { - // println!( - // "SYRUP [{}]: {} --> {} = {:?}", - // rpl.productCode.clone(), - // header_idx, - // repl.materialPathId.clone(), - // repl.syrupGram - // ); - // } - recipe_brewing_values_only[header_idx] += repl.syrupGram.as_i64().unwrap(); } recipe::MaterialType::Soda => { - // println!( - // "SODA [{}]: {} --> {} = {:?}", - // rpl.productCode.clone(), - // header_idx, - // repl.materialPathId.clone(), - // repl.syrupGram - // ); - recipe_brewing_values_only[header_idx] += repl.syrupGram.as_i64().unwrap(); }