Thoroughly fill out the day detail view model along with proper automated testing #179

Merged
savanni merged 7 commits from fitnesstrax/improved-view-model into main 2024-02-07 15:08:50 +00:00
1 changed files with 8 additions and 14 deletions
Showing only changes of commit a8bf540517 - Show all commits

View File

@ -110,6 +110,14 @@ impl DayDetailViewModel {
.partition(|r| r.data.is_weight());
let (step_records, records): (Vec<Record<TraxRecord>>, Vec<Record<TraxRecord>>) =
records.into_iter().partition(|r| r.data.is_steps());
if weight_records.len() > 1 {
eprintln!("warning: multiple weight records found for {}. This is unsupported and the one presented is unpredictable.", date.format("%Y-%m-%d"));
}
if step_records.len() > 1 {
eprintln!("warning: multiple step records found for {}. This is unsupported and the one presented is unpredictable.", date.format("%Y-%m-%d"));
}
Ok(Self {
provider: Arc::new(provider),
date,
@ -454,20 +462,6 @@ mod test {
count: 2500,
}),
},
Record {
id: RecordId::default(),
data: TraxRecord::Weight(ft_core::Weight {
date: oct_13.clone(),
weight: 91. * si::KG,
}),
},
Record {
id: RecordId::default(),
data: TraxRecord::Steps(ft_core::Steps {
date: oct_13.clone(),
count: 2750,
}),
},
Record {
id: RecordId::default(),
data: TraxRecord::BikeRide(ft_core::TimeDistance {