mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Merge pull request #2000 from amtriathlon/UserMetrics
Compute User Metrics after Builtins are completed
This commit is contained in:
@@ -166,10 +166,17 @@ RideMetric::computeMetrics(RideItem *item, Specification spec, const QStringList
|
||||
// generate worklist from metrics we know
|
||||
// bear in mind this can change as users add
|
||||
// and remove user metrics
|
||||
QStringList todo;
|
||||
// builtin User metrics are computed after builtins
|
||||
// since they don't have explicit dependencies set, yet.
|
||||
QStringList builtin;
|
||||
QStringList user;
|
||||
foreach(QString metric, metrics)
|
||||
if (factory.haveMetric(metric))
|
||||
todo << metric;
|
||||
if (factory.haveMetric(metric)) {
|
||||
if (factory.rideMetric(metric)->isUser())
|
||||
user << metric;
|
||||
else
|
||||
builtin << metric;
|
||||
}
|
||||
|
||||
// this is what we've completed as we go
|
||||
QHash<QString,RideMetric*> done;
|
||||
@@ -183,10 +190,11 @@ RideMetric::computeMetrics(RideItem *item, Specification spec, const QStringList
|
||||
item->metrics().resize(factory.metricCount());
|
||||
|
||||
// working through the todo list...
|
||||
while (!todo.isEmpty()) {
|
||||
while (!builtin.isEmpty() || !user.isEmpty()) {
|
||||
|
||||
// next one to do
|
||||
QString symbol = todo.takeFirst();
|
||||
// next one to do, builtins first then user defined
|
||||
QString symbol = builtin.isEmpty() ? user.takeFirst() :
|
||||
builtin.takeFirst();
|
||||
|
||||
// doesn't exist !
|
||||
if (!factory.haveMetric(symbol)) continue;
|
||||
@@ -200,8 +208,8 @@ RideMetric::computeMetrics(RideItem *item, Specification spec, const QStringList
|
||||
foreach (QString dep, deps) {
|
||||
if (!done.contains(dep)) {
|
||||
ready = false;
|
||||
if (!todo.contains(dep))
|
||||
todo.append(dep);
|
||||
if (!builtin.contains(dep))
|
||||
builtin.append(dep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,8 +240,8 @@ RideMetric::computeMetrics(RideItem *item, Specification spec, const QStringList
|
||||
|
||||
// we need to wait for our dependencies so add
|
||||
// to the back of the list
|
||||
if (!todo.contains(symbol))
|
||||
todo.append(symbol);
|
||||
if (!builtin.contains(symbol))
|
||||
builtin.append(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user