Overview - Fix up/down in Metric and RPE tiles

Add declaration for variable v inside the loop used to compute avg/min/max
to avoid affecting variable v in the outer scope, this is the minimum change
to fix the problem and the same pattern is present in other tiles.
Without this change up/down is based on the first activity of the same sport
in the previous 30 days, instead of the current one.
This commit is contained in:
Ale Martinez
2021-04-07 21:11:44 -03:00
parent a2b95df762
commit e3fda3cc0d

View File

@@ -518,7 +518,7 @@ RPEOverviewItem::setData(RideItem *item)
// only activities with matching sport flags
if (prior->isRun == item->isRun && prior->isSwim == item->isSwim) {
v = prior->getText("RPE", "0").toDouble();
double v = prior->getText("RPE", "0").toDouble();
if (std::isinf(v) || std::isnan(v)) v=0;
// new no zero value
@@ -593,6 +593,8 @@ MetricOverviewItem::setData(RideItem *item)
// only activities with matching sport flags
if (prior->isRun == item->isRun && prior->isSwim == item->isSwim) {
double v;
if (units == tr("seconds")) v = prior->getForSymbol(symbol, GlobalContext::context()->useMetricUnits);
else {
QString vs = prior->getStringForSymbol(symbol, GlobalContext::context()->useMetricUnits);