Adding bodymass support
This commit is contained in:
2542
train-cli/Cargo.lock
generated
Normal file
2542
train-cli/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -36,8 +36,9 @@ enum Commands {
|
||||
|
||||
/// time, either "2025-05-20T14:15:20+0200", "2025-12-24 18:00:00" or "17:15:00"
|
||||
time: Option<String>,
|
||||
}
|
||||
|
||||
},
|
||||
Latest {
|
||||
},
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@@ -45,6 +46,7 @@ fn main() {
|
||||
match &args.command {
|
||||
Commands::Report { exercise, runs, reps, kilos, time } => insert_training(exercise, runs, reps, kilos, time),
|
||||
Commands::Message { text, time } => insert_message(text, time),
|
||||
Commands::Latest {} => get_latest(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,3 +121,22 @@ fn insert_training (exercise: &String, runs: &i16, reps: &i16, kilos: &f32, time
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn get_latest () {
|
||||
let mut client = get_client();
|
||||
let res = client.query("with report as (select distinct on (t.exercise) t.time, t.exercise, t.kilos
|
||||
from training t inner join account a on a.id=t.account where a.login=$1 order by 2, 1 desc)
|
||||
select date_trunc('second', r.time), e.name, r.kilos from report r inner join exercise e on e.id=r.exercise order by 2",
|
||||
&[&whoami::username()]);
|
||||
match res {
|
||||
Ok(resultset) => {
|
||||
for r in resultset {
|
||||
let time : DateTime<FixedOffset> = r.get(0);
|
||||
let exercise : String= r.get(1);
|
||||
let kilos: Decimal = r.get(2);
|
||||
println!("{time} {exercise:>15} {kilos:>5}", time=time, exercise=exercise, kilos=kilos);
|
||||
}
|
||||
},
|
||||
Err(e) => println!("Report not fetched, since: {}", e)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user