36 lines
947 B
Rust
36 lines
947 B
Rust
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
let custom_unit = journal.maybe_get_custom_unit_for(ingestion);
|
||
|
|
||
|
println!(
|
||
|
"{}|{}|{}|{}|{}",
|
||
|
ingestion.substance_name,
|
||
|
format_ingestion_dose(&ingestion.dose, custom_unit.as_ref()),
|
||
|
format_ingestion_roa(ingestion, custom_unit.as_ref()),
|
||
|
ingestion.consumer,
|
||
|
format_ingestion_time(ingestion)
|
||
|
)
|
||
|
}
|
||
|
}
|