Skip non relevant metrics for RideSummary in Trends view

Adds isMetricRelevantForRides(specification, metric) to RideCache
to check if a metric isRelevant for some of the activities passing
the specification
Also reduces from 3 to 1 the calls to getRideTypeCounts
This commit is contained in:
Alejandro Martinez
2016-10-07 21:08:55 -03:00
parent 0cffd9c72c
commit ca262a28ce
3 changed files with 34 additions and 7 deletions

View File

@@ -902,3 +902,21 @@ RideCache::getRideTypeCounts(Specification specification, int& nActivities,
else nRides++;
}
}
bool
RideCache::isMetricRelevantForRides(Specification specification,
const RideMetric* metric)
{
bool isRelevant = false;
// loop through and aggregate
foreach (RideItem *ride, rides_) {
// skip filtered rides
if (!specification.pass(ride)) continue;
isRelevant = isRelevant || metric->isRelevantForRide(ride);
}
return isRelevant;
}