From bfa4b4b9779564193ff17114147f05ef72ebf82f Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Date: Mon, 16 Jan 2023 12:52:27 -0300 Subject: [PATCH] DataFilter - Metric aggretation honors AggregateZero and Count When computing metric averages --- src/Core/DataFilter.cpp | 8 +++++--- src/Core/RideCache.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Core/DataFilter.cpp b/src/Core/DataFilter.cpp index 4837b80b7..155619645 100644 --- a/src/Core/DataFilter.cpp +++ b/src/Core/DataFilter.cpp @@ -4912,6 +4912,8 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, const Result &x, long it, R double minimum=0; double maximum=0; double count=0; + // do we aggregate zero values ? + bool aggZero = e ? e->aggregateZero() : true; // loop through rides for daterange foreach(RideItem *ride, m->context->athlete->rideCache->rides()) { @@ -4929,14 +4931,14 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, const Result &x, long it, R value= QTime(0,0,0).secsTo(ride->dateTime.time()); if (wantstrings) asstring = ride->dateTime.toString("hh:mm:ss"); } else { - value = ride->getForSymbol(df->lookupMap.value(symbol,""), GlobalContext::context()->useMetricUnits); + value = ride->getForSymbol(o_symbol, GlobalContext::context()->useMetricUnits); if (wantstrings) e ? asstring = e->toString(value) : "(null)"; } // keep count of time for ride, useful when averaging count++; - double duration = ride->getForSymbol("workout_time"); - totalduration += duration; + double duration = ride->getCountForSymbol(o_symbol); + if (value || aggZero) totalduration += duration; withduration += value * duration; runningtotal += value; if (count==1) { diff --git a/src/Core/RideCache.cpp b/src/Core/RideCache.cpp index 2cd26f7c2..2e739afe6 100644 --- a/src/Core/RideCache.cpp +++ b/src/Core/RideCache.cpp @@ -607,7 +607,7 @@ RideCache::getAggregate(QString name, Specification spec, bool useMetricUnits, b // get this value double value = item->getForSymbol(name); - double count = item->getForSymbol("workout_time"); // for averaging + double count = item->getCountForSymbol(name); // for averaging // check values are bounded, just in case if (std::isnan(value) || std::isinf(value)) value = 0;