Render and be able to edit bike rides (and sorta other time distance workouts) #169

Merged
savanni merged 13 commits from fitnesstrax/time-distance-workout into main 2024-02-09 00:05:26 +00:00
8 changed files with 9 additions and 24 deletions
Showing only changes of commit 4acf034b8d - Show all commits

View File

@ -201,7 +201,7 @@ mod test {
impl Recordable for WeightRecord { impl Recordable for WeightRecord {
fn timestamp(&self) -> Timestamp { fn timestamp(&self) -> Timestamp {
Timestamp::Date(self.date.clone()) Timestamp::Date(self.date)
} }
fn tags(&self) -> Vec<String> { fn tags(&self) -> Vec<String> {

View File

@ -20,7 +20,7 @@ extern crate emseries;
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use chrono::{format::Fixed, prelude::*}; use chrono::{prelude::*};
use chrono_tz::Etc::UTC; use chrono_tz::Etc::UTC;
use dimensioned::si::{Kilogram, Meter, Second, M, S}; use dimensioned::si::{Kilogram, Meter, Second, M, S};
@ -42,7 +42,7 @@ mod test {
impl Recordable for BikeTrip { impl Recordable for BikeTrip {
fn timestamp(&self) -> Timestamp { fn timestamp(&self) -> Timestamp {
Timestamp::DateTime(self.datetime.clone()) Timestamp::DateTime(self.datetime)
} }
fn tags(&self) -> Vec<String> { fn tags(&self) -> Vec<String> {
Vec::new() Vec::new()
@ -99,7 +99,7 @@ mod test {
] ]
} }
fn run_test<T>(test: T) -> () fn run_test<T>(test: T)
where where
T: FnOnce(tempfile::TempPath), T: FnOnce(tempfile::TempPath),
{ {
@ -108,7 +108,7 @@ mod test {
test(tmp_path); test(tmp_path);
} }
fn run<T>(test: T) -> () fn run<T>(test: T)
where where
T: FnOnce(Series<BikeTrip>), T: FnOnce(Series<BikeTrip>),
{ {
@ -280,8 +280,7 @@ mod test {
UTC.with_ymd_and_hms(2011, 11, 04, 0, 0, 0) UTC.with_ymd_and_hms(2011, 11, 04, 0, 0, 0)
.unwrap() .unwrap()
.with_timezone(&FixedOffset::east_opt(0).unwrap()), .with_timezone(&FixedOffset::east_opt(0).unwrap()),
) ),
.into(),
true, true,
), ),
|l, r| l.timestamp().cmp(&r.timestamp()), |l, r| l.timestamp().cmp(&r.timestamp()),

View File

@ -99,10 +99,6 @@ impl AppWindow {
window.set_content(Some(&navigation)); window.set_content(Some(&navigation));
window.present(); window.present();
let gesture = gtk::GestureClick::new();
gesture.connect_released(|_, _, _, _| println!("detected gesture"));
layout.add_controller(gesture);
let s = Self { let s = Self {
app: ft_app, app: ft_app,
layout, layout,

View File

@ -264,7 +264,6 @@ impl DayEdit {
} }
fn add_row(&self, workout: Record<TraxRecord>) { fn add_row(&self, workout: Record<TraxRecord>) {
println!("adding a row for {:?}", workout);
let workout_rows = self.imp().workout_rows.borrow(); let workout_rows = self.imp().workout_rows.borrow();
#[allow(clippy::single_match)] #[allow(clippy::single_match)]

View File

@ -11,7 +11,8 @@ FitnessTrax is distributed in the hope that it will be useful, but WITHOUT ANY W
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. General Public License for more details.
You should have received a copy of the GNU General Public License along with FitnessTrax. If not, see <https://www.gnu.org/licenses/>. You should have received a copy of the GNU General Public License along with FitnessTrax. If not,
see <https://www.gnu.org/licenses/>.
*/ */
mod action_group; mod action_group;

View File

@ -25,7 +25,7 @@ use dimensioned::si;
use ft_core::{TimeDistance, TimeDistanceActivity}; use ft_core::{TimeDistance, TimeDistanceActivity};
use glib::Object; use glib::Object;
use gtk::{prelude::*, subclass::prelude::*}; use gtk::{prelude::*, subclass::prelude::*};
use std::{cell::RefCell, rc::Rc}; use std::{rc::Rc, cell::RefCell};
pub fn time_distance_summary( pub fn time_distance_summary(
distance: DistanceFormatter, distance: DistanceFormatter,

View File

@ -256,14 +256,6 @@ impl From<si::Second<f64>> for DurationFormatter {
} }
} }
/*
fn take_digits(s: String) -> String {
s.chars()
.take_while(|t| t.is_ascii_digit())
.collect::<String>()
}
*/
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;

View File

@ -230,12 +230,10 @@ impl DayDetailViewModel {
} }
pub fn update_record(&self, update: Record<TraxRecord>) { pub fn update_record(&self, update: Record<TraxRecord>) {
println!("updating a record: {:?}", update);
let mut records = self.records.write().unwrap(); let mut records = self.records.write().unwrap();
records records
.entry(update.id) .entry(update.id)
.and_modify(|record| record.set_value(update.data)); .and_modify(|record| record.set_value(update.data));
println!("record updated: {:?}", records.get(&update.id));
} }
pub fn records(&self) -> Vec<Record<TraxRecord>> { pub fn records(&self) -> Vec<Record<TraxRecord>> {