Show and edit the details of a day #133

Merged
savanni merged 9 commits from fitnesstrax/day-detail into main 2023-12-29 16:01:36 +00:00
4 changed files with 49 additions and 34 deletions
Showing only changes of commit 6d9e2ea382 - Show all commits

View File

@ -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;

View File

@ -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| {

View File

@ -173,7 +173,6 @@ impl From<Vec<Record<TraxRecord>>> 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,19 +180,30 @@ mod test {
#[test]
fn groups_records() {
let records = vec![
TraxRecord::Steps(Steps {
Record {
id: RecordId::default(),
data: TraxRecord::Steps(Steps {
date: NaiveDate::from_ymd_opt(2023, 10, 13).unwrap(),
count: 1500,
}),
TraxRecord::Weight(Weight {
},
Record {
id: RecordId::default(),
data: TraxRecord::Weight(Weight {
date: NaiveDate::from_ymd_opt(2023, 10, 13).unwrap(),
weight: 85. * KG,
}),
TraxRecord::Weight(Weight {
},
Record {
id: RecordId::default(),
data: TraxRecord::Weight(Weight {
date: NaiveDate::from_ymd_opt(2023, 10, 14).unwrap(),
weight: 86. * KG,
}),
TraxRecord::BikeRide(TimeDistance {
},
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)
@ -202,7 +212,10 @@ mod test {
duration: Some(150. * S),
comments: Some("Test Comments".to_owned()),
}),
TraxRecord::BikeRide(TimeDistance {
},
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)
@ -211,6 +224,7 @@ mod test {
duration: Some(150. * S),
comments: Some("Test Comments".to_owned()),
}),
},
];
let groups = GroupedRecords::from(records).0;

View File

@ -1,3 +1,4 @@
mod legacy;
mod types;
pub use types::{RecordType, Steps, TimeDistance, TraxRecord, Weight};