From b8212df55a7bc2ff919d0ff0a954527abf772e54 Mon Sep 17 00:00:00 2001 From: Joe Burnard Date: Wed, 7 Feb 2024 21:11:25 +0000 Subject: [PATCH] configurable number of import days --- src/entries.rs | 2 ++ src/main.rs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/entries.rs b/src/entries.rs index d67571c..7831539 100644 --- a/src/entries.rs +++ b/src/entries.rs @@ -457,6 +457,7 @@ pub enum Measure { Ml, UsFl, L, + Cl, } impl<'de> Deserialize<'de> for Measure { @@ -472,6 +473,7 @@ impl<'de> Deserialize<'de> for Measure { "ml" => Measure::Ml, "us fl" | "usfl" => Measure::UsFl, "l" => Measure::L, + "cl" => Measure::Cl, _ => return Err(D::Error::custom(format!("unhandled variant: {}", s2))), }) } diff --git a/src/main.rs b/src/main.rs index 823b989..58df248 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,13 +15,15 @@ async fn main() -> Result<(), Box> { tracing_subscriber::fmt::init(); + let import_days = std::env::var("NUTRACHECK_IMPORT_DAYS")?.parse::()?; + let mongo_client = mongo::Client::new_from_env().await?; let nc_client = nutracheck::Client::new_from_env().await?; let todays_date = Utc::now().date_naive(); - for date in dateiter::DateRange(todays_date - Duration::weeks(52), todays_date) { + for date in dateiter::DateRange(todays_date - Duration::days(import_days), todays_date) { let entries = nc_client.entries(date).await.expect("getting entries"); mongo_client.insert_entries(date, entries).await?;