Create a new app for fitnesstrax and start setting up the record data structures #114

Merged
savanni merged 7 commits from fitnesstrax-record into main 2023-12-07 14:17:59 +00:00
4 changed files with 27 additions and 6 deletions
Showing only changes of commit 83a4839b1d - Show all commits

4
Cargo.lock generated
View File

@ -976,8 +976,6 @@ checksum = "8fcfdc7a0362c9f4444381a9e697c79d435fe65b52a37466fc2c1184cee9edc6"
name = "fitnesstrax"
version = "0.1.0"
dependencies = [
"chrono",
"chrono-tz",
"gio",
"glib",
"glib-build-tools 0.18.0",
@ -1134,6 +1132,8 @@ dependencies = [
name = "ft-core"
version = "0.1.0"
dependencies = [
"chrono",
"chrono-tz",
"dimensioned 0.8.0",
"emseries",
"serde 1.0.188",

View File

@ -7,8 +7,6 @@ edition = "2021"
[dependencies]
adw = { version = "0.5", package = "libadwaita", features = [ "v1_2" ] }
chrono = { version = "0.4" }
chrono-tz = { version = "0.8" }
gio = { version = "0.18" }
glib = { version = "0.18" }
gtk = { version = "0.7", package = "gtk4", features = [ "v4_8" ] }

View File

@ -6,6 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
chrono = { version = "0.4" }
chrono-tz = { version = "0.8" }
dimensioned = { version = "0.8", features = [ "serde" ] }
emseries = { path = "../../emseries" }
serde = { version = "1", features = [ "derive" ] }

View File

@ -69,7 +69,18 @@ pub enum TraxRecord {
impl Recordable for TraxRecord {
fn timestamp(&self) -> Timestamp {
unimplemented!()
match self {
TraxRecord::BikeRide(rec) => Timestamp::DateTime(rec.datetime.clone()),
TraxRecord::Pushups => unimplemented!(),
TraxRecord::Row(rec) => Timestamp::DateTime(rec.datetime.clone()),
TraxRecord::Run(rec) => Timestamp::DateTime(rec.datetime.clone()),
TraxRecord::Situps => unimplemented!(),
TraxRecord::Squats => unimplemented!(),
TraxRecord::Steps(rec) => Timestamp::Date(rec.date),
TraxRecord::Swim(rec) => Timestamp::DateTime(rec.datetime.clone()),
TraxRecord::Walk(rec) => Timestamp::DateTime(rec.datetime.clone()),
TraxRecord::Weight(rec) => Timestamp::Date(rec.date),
}
}
fn tags(&self) -> Vec<String> {
@ -86,6 +97,16 @@ mod 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();
let mut series: Series<TraxRecord> = Series::open(&path).unwrap();
let record = TraxRecord::Steps(Steps {
date: NaiveDate::from_ymd_opt(2023, 1, 1).unwrap(),
count: 1000,
});
let id = series.put(record.clone()).unwrap();
let record_ = series.get(&id).unwrap();
assert_eq!(record_, record);
}
}