Metric Aggregation ::aggregateZero() method

.. when aggregating metrics across rides we were being inconsistent
   with regards how we handled zero values; we sometimes included them
   and sometimes didn't.

.. now added a metric method bool aggregateZero() that returns true
   if aggregates need to include zero values

.. this has been implemented where averages are aggregated.
This commit is contained in:
Mark Liversedge
2014-06-20 11:19:55 +01:00
parent 5a9cd0f7bd
commit cf445e87bd
4 changed files with 25 additions and 10 deletions

View File

@@ -945,6 +945,9 @@ LTMWindow::refreshDataTable()
// ignore estimates for now XXX just to stop it crashing
if (metricDetail.type == METRIC_ESTIMATE) continue;
// do we aggregate zero values ?
bool aggZero = metricDetail.metric ? metricDetail.metric->aggregateZero() : false;
QList<SummaryMetrics> *data = NULL; // source data (metrics, bests etc)
GroupedData a; // aggregated data
@@ -1025,7 +1028,9 @@ LTMWindow::refreshDataTable()
a.y[n] = value;
a.x[n] = currentDay - groupForDate(settings.start.date());
secondsPerGroupBy = seconds; // reset for new group
if (value || aggZero) secondsPerGroupBy = seconds; // reset for new group
} else {
// sum totals, average averages and choose best for Peaks
int type = metricDetail.metric ? metricDetail.metric->type() : RideMetric::Average;
@@ -1047,7 +1052,7 @@ LTMWindow::refreshDataTable()
// average should be calculated taking into account
// the duration of the ride, otherwise high value but
// short rides will skew the overall average
a.y[n] = ((a.y[n]*secondsPerGroupBy)+(seconds*value)) / (secondsPerGroupBy+seconds);
if (value || aggZero) a.y[n] = ((a.y[n]*secondsPerGroupBy)+(seconds*value)) / (secondsPerGroupBy+seconds);
break;
}
case RideMetric::Low: