use journal::{ journal::JournalType, types::{Consumer, Experience}, }; use crate::formatting::{format_ingestion_dose, format_ingestion_roa, format_ingestion_time}; pub fn print_ingestion_log( journal: &JournalType, experience: &Experience, substance_filter: Option<&Vec>, consumer_filter: Option<&Vec>, ) { for ingestion in journal .get_experience_ingestions(experience.id) .expect("could not find ingestions for experience") .iter() { if let Some(substance_filter) = substance_filter { if !substance_filter.contains(&ingestion.substance_name) { continue; } } if let Some(consumer_filter) = consumer_filter { if !consumer_filter.contains(&ingestion.consumer) { continue; } } let custom_unit = journal.maybe_custom_unit(ingestion); // println!("{:#?} {:#?}", &ingestion, &custom_unit); println!( "{}|{}|{}|{}|{}", ingestion.substance_name, format_ingestion_dose(&ingestion.dose, custom_unit.map(|f| &f.dose)), format_ingestion_roa(ingestion, custom_unit), ingestion.consumer, format_ingestion_time(ingestion) ) } }