API List MMP

.. returns the mean max power array for a
   given ride in csv format.

   e.g. http://http://localhost:12021/athlete/meanmax/2015_08_09_10_59_09.json

   will return the power mean max data in
   csv format.
This commit is contained in:
Mark Liversedge
2015-09-09 21:36:15 +01:00
parent 42248d5584
commit cac9b84859
3 changed files with 89 additions and 2 deletions

View File

@@ -23,6 +23,7 @@
#include "RideDB.h"
#include "RideFile.h"
#include "RideFileCache.h"
#include "CsvRideFile.h"
#include <QTemporaryFile>
@@ -80,7 +81,7 @@ APIWebService::athleteData(QStringList &paths, HttpRequest &request, HttpRespons
}
// GET MMP
if (paths[0] == "mmp") {
if (paths[0] == "meanmax") {
paths.removeFirst();
listMMP(athlete, paths, request, response);
return;
@@ -311,5 +312,17 @@ APIWebService::listMMP(QString athlete, QStringList paths, HttpRequest &request,
{
// list activities and associated metrics
response.setHeader("Content-Type", "text; charset=ISO-8859-1");
response.write("get mmp under construction");
QString filename=paths[0];
QString CPXfilename = home.absolutePath() + "/" + athlete + "/cache/" + QFileInfo(filename).completeBaseName() + ".cpx";
response.bwrite("secs, watts\n");
if (QFileInfo(CPXfilename).exists()) {
int secs=0;
foreach(float value, RideFileCache::meanMaxFor(CPXfilename, RideFile::watts)) {
if (secs >0) response.bwrite(QString("%1, %2\n").arg(secs).arg(value).toLocal8Bit());
secs++;
}
}
response.flush();
}