From a5bb6947a7b91e1ab43cbded5caa44eb8f10ff0d Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Thu, 24 Jan 2013 21:42:23 +0000 Subject: [PATCH] TRIMP fallback to workout time if time riding 0 --- src/DBAccess.cpp | 3 ++- src/TRIMPPoints.cpp | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/DBAccess.cpp b/src/DBAccess.cpp index fb6cc7bc9..c63d4a300 100644 --- a/src/DBAccess.cpp +++ b/src/DBAccess.cpp @@ -59,8 +59,9 @@ // 40 20 Oct 2012 Mark Liversedge Lucene search/filter and checkbox metadata field // 41 27 Oct 2012 Mark Liversedge Lucene switched to StandardAnalyzer and search all texts by default // 42 03 Dec 2012 Mark Liversedge W/KG ridefilecache changes - force a rebuild. +// 43 24 Jan 2012 Mark Liversedge TRIMP update -static int DBSchemaVersion = 42; +static int DBSchemaVersion = 43; DBAccess::DBAccess(MainWindow* main, QDir home) : main(main), home(home) { diff --git a/src/TRIMPPoints.cpp b/src/TRIMPPoints.cpp index 37bdb68c4..dfd12c966 100644 --- a/src/TRIMPPoints.cpp +++ b/src/TRIMPPoints.cpp @@ -70,14 +70,18 @@ class TRIMPPoints : public RideMetric { restHr = rideFile->getTag("Rest HR", QString("%1").arg(restHr)).toDouble(); assert(deps.contains("time_riding")); + assert(deps.contains("workout_time")); assert(deps.contains("average_hr")); //const RideMetric *workoutTimeMetric = deps.value("workout_time"); const RideMetric *timeRidingMetric = deps.value("time_riding"); const RideMetric *averageHrMetric = deps.value("average_hr"); + const RideMetric *durationMetric = deps.value("workout_time"); assert(timeRidingMetric); + assert(durationMetric); assert(averageHrMetric); - double secs = timeRidingMetric->value(true); + double secs = timeRidingMetric->value(true) ? timeRidingMetric->value(true) : + durationMetric->value(true);; double hr = averageHrMetric->value(true); //TRIMP: = t x %HRR x 0.64e1,92(%HRR)