2024-11-20 19:15:07 +00:00
|
|
|
use journal::types::{Consumer, Experience, Journal};
|
|
|
|
|
|
|
|
use crate::formatting::{format_ingestion_dose, format_ingestion_roa, format_ingestion_time};
|
|
|
|
|
|
|
|
pub fn print_ingestion_log(
|
|
|
|
journal: &Journal,
|
|
|
|
experience: &Experience,
|
|
|
|
substance_filter: Option<&Vec<String>>,
|
|
|
|
consumer_filter: Option<&Vec<Consumer>>,
|
|
|
|
) {
|
|
|
|
for ingestion in experience.ingestions.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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-21 07:20:46 +00:00
|
|
|
let custom_unit = journal.maybe_custom_unit(ingestion);
|
|
|
|
|
|
|
|
//println!("{:#?} {:#?}", &ingestion, &custom_unit);
|
2024-11-20 19:15:07 +00:00
|
|
|
|
|
|
|
println!(
|
|
|
|
"{}|{}|{}|{}|{}",
|
|
|
|
ingestion.substance_name,
|
2024-11-21 07:20:46 +00:00
|
|
|
format_ingestion_dose(&ingestion.dose, custom_unit.as_ref().map(|f| &f.dose)),
|
2024-11-20 19:15:07 +00:00
|
|
|
format_ingestion_roa(ingestion, custom_unit.as_ref()),
|
|
|
|
ingestion.consumer,
|
|
|
|
format_ingestion_time(ingestion)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|