Create a new app for fitnesstrax and start setting up the record data structures #114
|
@ -764,6 +764,7 @@ checksum = "a0b0a86c5d31c93238ff4b694fa31f3acdf67440770dc314c57d90e433914397"
|
|||
dependencies = [
|
||||
"generic-array 0.14.7",
|
||||
"num-traits",
|
||||
"serde 1.0.188",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
|
@ -984,6 +985,8 @@ dependencies = [
|
|||
"glib-build-tools 0.18.0",
|
||||
"gtk4",
|
||||
"libadwaita",
|
||||
"serde 1.0.188",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
|
|
|
@ -17,13 +17,17 @@ path = "src/main.rs"
|
|||
adw = { version = "0.5", package = "libadwaita", features = [ "v1_2" ] }
|
||||
chrono = { version = "0.4" }
|
||||
chrono-tz = { version = "0.8" }
|
||||
dimensioned = { version = "0.8" }
|
||||
dimensioned = { version = "0.8", features = [ "serde" ] }
|
||||
emseries = { path = "../emseries" }
|
||||
gio = { version = "0.18" }
|
||||
glib = { version = "0.18" }
|
||||
gtk = { version = "0.7", package = "gtk4", features = [ "v4_8" ] }
|
||||
serde = { version = "1", features = [ "derive" ] }
|
||||
tokio = { version = "1.34", features = [ "full" ] }
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "*"
|
||||
|
||||
[build-dependencies]
|
||||
glib-build-tools = "0.18"
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use chrono::NaiveDate;
|
||||
use dimensioned::si;
|
||||
use emseries::DateTimeTz;
|
||||
use emseries::{DateTimeTz, Recordable, Timestamp};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// SetRep represents workouts like pushups or situps, which involve doing a "set" of a number of
|
||||
/// actions, resting, and then doing another set.
|
||||
|
@ -15,6 +16,7 @@ pub struct SetRep {
|
|||
}
|
||||
|
||||
/// The number of steps one takes in a single day.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Steps {
|
||||
date: NaiveDate,
|
||||
count: u32,
|
||||
|
@ -25,6 +27,7 @@ pub struct Steps {
|
|||
/// record a single 30-km workout if I go on a long-distanec ride. Or I might record multiple 5km
|
||||
/// workouts if I am out running errands. Distance and Duration are both optional because different
|
||||
/// people have different priorities and may choose to measure different things.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct TimeDistance {
|
||||
/// The precise time (and the relevant timezone) of the workout. One of the edge cases that I
|
||||
/// account for is that a ride which occurred at 11pm in one timezone would then count as 1am
|
||||
|
@ -43,12 +46,14 @@ pub struct TimeDistance {
|
|||
|
||||
/// A singular daily weight measurement. Weight changes slowly enough that it seems unlikely to
|
||||
/// need to track more than a single weight in a day.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Weight {
|
||||
date: NaiveDate,
|
||||
weight: si::Kilogram<f64>,
|
||||
}
|
||||
|
||||
/// The unified data structure for all records that are part of the app.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub enum TraxRecord {
|
||||
BikeRide(TimeDistance),
|
||||
Pushups,
|
||||
|
@ -61,3 +66,26 @@ pub enum TraxRecord {
|
|||
Walk(TimeDistance),
|
||||
Weight(Weight),
|
||||
}
|
||||
|
||||
impl Recordable for TraxRecord {
|
||||
fn timestamp(&self) -> Timestamp {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn tags(&self) -> Vec<String> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use emseries::Series;
|
||||
|
||||
#[test]
|
||||
fn can_record_records() {
|
||||
let file = tempfile::NamedTempFile::new().expect("a temporary file");
|
||||
let path = file.into_temp_path();
|
||||
let series: Series<TraxRecord> = Series::open(&path).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue