From 6d9e2ea38266754cf51ab59959427591117d41d6 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Wed, 27 Dec 2023 17:14:47 -0500 Subject: [PATCH] Switch to the updated emseries record type --- fitnesstrax/app/src/app.rs | 2 +- fitnesstrax/app/src/components/day.rs | 4 +- fitnesstrax/app/src/views/historical_view.rs | 76 ++++++++++++-------- fitnesstrax/core/src/lib.rs | 1 + 4 files changed, 49 insertions(+), 34 deletions(-) diff --git a/fitnesstrax/app/src/app.rs b/fitnesstrax/app/src/app.rs index f8de8fc..ef798d3 100644 --- a/fitnesstrax/app/src/app.rs +++ b/fitnesstrax/app/src/app.rs @@ -18,7 +18,7 @@ use chrono::NaiveDate; use emseries::{time_range, Record, RecordId, Series, Timestamp}; use ft_core::TraxRecord; use std::{ - path::{Path, PathBuf}, + path::PathBuf, sync::{Arc, RwLock}, }; use tokio::runtime::Runtime; diff --git a/fitnesstrax/app/src/components/day.rs b/fitnesstrax/app/src/components/day.rs index f6f8b98..690d9d3 100644 --- a/fitnesstrax/app/src/components/day.rs +++ b/fitnesstrax/app/src/components/day.rs @@ -157,10 +157,10 @@ impl DayDetail { }); let weight_view = match weight_record { - Some((unique_id, record)) => WeightView::new(Some(record), move |weight| { + Some((id, record)) => WeightView::new(Some(record.clone()), move |weight| { println!( "on_blur on the weight view. Need to record {:?}, {:?}", - unique_id, weight + id, weight ); }), None => WeightView::new(None, |weight| { diff --git a/fitnesstrax/app/src/views/historical_view.rs b/fitnesstrax/app/src/views/historical_view.rs index 79c85dd..962fef2 100644 --- a/fitnesstrax/app/src/views/historical_view.rs +++ b/fitnesstrax/app/src/views/historical_view.rs @@ -173,7 +173,6 @@ impl From>> for GroupedRecords { mod test { use super::GroupedRecords; use chrono::{FixedOffset, NaiveDate, TimeZone}; - use chrono_tz::America::Anchorage; use dimensioned::si::{KG, M, S}; use emseries::{Record, RecordId}; use ft_core::{Steps, TimeDistance, TraxRecord, Weight}; @@ -181,36 +180,51 @@ mod test { #[test] fn groups_records() { let records = vec![ - TraxRecord::Steps(Steps { - date: NaiveDate::from_ymd_opt(2023, 10, 13).unwrap(), - count: 1500, - }), - TraxRecord::Weight(Weight { - date: NaiveDate::from_ymd_opt(2023, 10, 13).unwrap(), - weight: 85. * KG, - }), - TraxRecord::Weight(Weight { - date: NaiveDate::from_ymd_opt(2023, 10, 14).unwrap(), - weight: 86. * KG, - }), - TraxRecord::BikeRide(TimeDistance { - datetime: FixedOffset::west_opt(10 * 60 * 60) - .unwrap() - .with_ymd_and_hms(2019, 6, 15, 12, 0, 0) - .unwrap(), - distance: Some(1000. * M), - duration: Some(150. * S), - comments: Some("Test Comments".to_owned()), - }), - TraxRecord::BikeRide(TimeDistance { - datetime: FixedOffset::west_opt(10 * 60 * 60) - .unwrap() - .with_ymd_and_hms(2019, 6, 15, 23, 0, 0) - .unwrap(), - distance: Some(1000. * M), - duration: Some(150. * S), - comments: Some("Test Comments".to_owned()), - }), + Record { + id: RecordId::default(), + data: TraxRecord::Steps(Steps { + date: NaiveDate::from_ymd_opt(2023, 10, 13).unwrap(), + count: 1500, + }), + }, + Record { + id: RecordId::default(), + data: TraxRecord::Weight(Weight { + date: NaiveDate::from_ymd_opt(2023, 10, 13).unwrap(), + weight: 85. * KG, + }), + }, + Record { + id: RecordId::default(), + data: TraxRecord::Weight(Weight { + date: NaiveDate::from_ymd_opt(2023, 10, 14).unwrap(), + weight: 86. * KG, + }), + }, + Record { + id: RecordId::default(), + data: TraxRecord::BikeRide(TimeDistance { + datetime: FixedOffset::west_opt(10 * 60 * 60) + .unwrap() + .with_ymd_and_hms(2019, 6, 15, 12, 0, 0) + .unwrap(), + distance: Some(1000. * M), + duration: Some(150. * S), + comments: Some("Test Comments".to_owned()), + }), + }, + Record { + id: RecordId::default(), + data: TraxRecord::BikeRide(TimeDistance { + datetime: FixedOffset::west_opt(10 * 60 * 60) + .unwrap() + .with_ymd_and_hms(2019, 6, 15, 23, 0, 0) + .unwrap(), + distance: Some(1000. * M), + duration: Some(150. * S), + comments: Some("Test Comments".to_owned()), + }), + }, ]; let groups = GroupedRecords::from(records).0; diff --git a/fitnesstrax/core/src/lib.rs b/fitnesstrax/core/src/lib.rs index b206602..207f483 100644 --- a/fitnesstrax/core/src/lib.rs +++ b/fitnesstrax/core/src/lib.rs @@ -1,3 +1,4 @@ mod legacy; + mod types; pub use types::{RecordType, Steps, TimeDistance, TraxRecord, Weight};