Fix RideFileCache threaded db access

The call to RideFile::getWeight() in RideFileCache
computation ends up with a call the read the measures
table in the DB. This is BAD since it is called from
a thread.

We now call getWeight() in the metric aggregator before
launching the ridefilecache computation -- this will cache
the weight and avoid db access.

I've also removed the duplicate code in the w/kg metric code
too and it should be marginally faster at computing metrics
now.

BIG THANKS TO ILJA BOOIJ FOR HIGHLIGHTING THIS, DESPITE MY
INITIAL SCEPTICISM. I OWE HIM A PINT (OR TWO) :)

Fixes #604
This commit is contained in:
Mark Liversedge
2013-05-19 19:06:28 +01:00
parent a89dc3bb97
commit 1aadc19f36
3 changed files with 14 additions and 25 deletions

View File

@@ -63,8 +63,9 @@
// 44 19 Apr 2013 Mark Liversedge Aerobic Decoupling precision reduced to 1pt
// 45 09 May 2013 Mark Liversedge Added 2,3,8 and 90m peak power for fatigue profiling
// 46 13 May 2013 Mark Liversedge Handle absence of speed in metric calculations
// 47 17 May 2013 Mark Liversedge Reimplementation of w/kg and ride->getWeight()
int DBSchemaVersion = 46;
int DBSchemaVersion = 47;
DBAccess::DBAccess(MainWindow* main, QDir home) : main(main), home(home)
{