[chronojump-server] Results with all needed repetition params
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump-server] Results with all needed repetition params
- Date: Wed, 17 May 2017 22:02:31 +0000 (UTC)
commit 765b73d41abd0b6d5081b8fc402b021ae43fec09
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu May 18 00:00:30 2017 +0200
Results with all needed repetition params
chronojump-flask/chronojump_server.py | 22 ++++++++++-----
chronojump-flask/templates/results.html | 38 ++++++++++++++++++-------
main.py | 30 +++++++++++++++++---
tables.txt | 45 +++++++++++++++++++-----------
4 files changed, 95 insertions(+), 40 deletions(-)
---
diff --git a/chronojump-flask/chronojump_server.py b/chronojump-flask/chronojump_server.py
index d3fb62f..6a6418c 100644
--- a/chronojump-flask/chronojump_server.py
+++ b/chronojump-flask/chronojump_server.py
@@ -52,12 +52,20 @@ def Results():
else:
personStr = " AND person.id = " + personId
- cursor.execute("SELECT results.dt, person.name, station.name, results.resistance, results.exerciseName,
results.meanPowerBestRep, results.repsAbove50pBest, results.comments" +
- " FROM results, person, station " +
- " WHERE results.personId = person.id " +
- " AND results.stationId = station.id " +
- personStr + dateStr + stationStr +
- " ORDER by results.id DESC")
+ bySpeed = True
+ repetitonString = ""
+ if bySpeed:
+ repString = "numBySpeed, rangeBySpeed, vmeanBySpeed, vmaxBySpeed, pmeanBySpeed, pmaxBySpeed";
+ else:
+ repString = "numByPower, rangeByPower, vmeanByPower, vmaxByPower, pmeanByPower, pmaxByPower";
+
+ cursor.execute("SELECT results.dt, person.name, station.name, results.resistance, results.exerciseName,
" +
+ repString + ", comments" +
+ " FROM results, person, station " +
+ " WHERE results.personId = person.id " +
+ " AND results.stationId = station.id " +
+ personStr + dateStr + stationStr +
+ " ORDER by results.id DESC")
results = cursor.fetchall()
cursor.execute("SELECT results.personId, person.name FROM results, " +
@@ -67,7 +75,7 @@ def Results():
cursor.execute("SELECT * FROM station")
stations = cursor.fetchall()
- return render_template('results.html', header=getHeader("Resultats"), date=date, pId=personId,
sId=stationId, results=results, persons=persons, stations=stations)
+ return render_template('results.html', header=getHeader("Resultats"), date=date, pId=personId,
sId=stationId, bySpeed = bySpeed, results=results, persons=persons, stations=stations)
@app.route('/player_list',methods = ['POST', 'GET'])
def list():
diff --git a/chronojump-flask/templates/results.html b/chronojump-flask/templates/results.html
index 07130a1..6976295 100644
--- a/chronojump-flask/templates/results.html
+++ b/chronojump-flask/templates/results.html
@@ -123,13 +123,19 @@
<thead>
<th>Data</th>
{% if pId == "All" %}
- <th>Jugador</th>
+ <th>Jugador</th>
+ {% endif %}
+ {% if sId == "All" %}
+ <th>Estació</th>
{% endif %}
- <th>Estació</th>
<th>Càrrega</th>
<th>Exercici</th>
- <th>Potencia mitjana</th>
- <th>Repeticions bones</th>
+ <th>[ num</th>
+ <th>rang</th>
+ <th>Vm</th>
+ <th>VM</th>
+ <th>Pm</th>
+ <th>PM ]</th>
<th>Comentaris</th>
</thead>
@@ -137,14 +143,24 @@
<tr>
<td>{{row[0]}}</td>
{% if pId == "All" %}
- <td>{{row[1]}}</td>
+ <td>{{row[1]}}</td>
+ {% endif %}
+ {% if sId == "All" %}
+ <td>{{row[2]}}</td>
{% endif %}
- <td>{{row[2]}}</td>
- <td>{{row[3]}}</td>
- <td>{{row[4]}}</td>
- <td>{{ row[5] if row[5] != None }}</td>
- <td>{{ row[6] if row[6] != None }}</td>
- <td>{{row[7]}}</td>
+ <td>{{row[3]}}</td>
+ <td>{{row[4]}}</td>
+ <!--
+ <td>{{ row[5] if row[5] != None }}</td>
+ <td>{{ row[6] if row[6] != None }}</td>
+ -->
+ <td>{{row[5]}}</td>
+ <td>{{row[6]}}</td>
+ <td>{{row[7]}}</td>
+ <td>{{row[8]}}</td>
+ <td>{{row[9]}}</td>
+ <td>{{row[10]}}</td>
+ <td>{{row[11]}}</td>
</tr>
{% endfor %}
</table>
diff --git a/main.py b/main.py
index 3dd3563..f814ca1 100755
--- a/main.py
+++ b/main.py
@@ -106,17 +106,37 @@ def uploadEncoderData():
stationId = content.get('stationId', 1)
resistance = content.get('resistance', 0)
exerciseName = content.get('exerciseName', "unknown")
- meanPowerBestRep = content.get('meanPowerBestRep', 0)
- repsAbove50pBest = content.get('repsAbove50pBest', 0)
- meanPowerBestRep = str(meanPowerBestRep).replace(',', '.')
+ numBySpeed = content.get('numBySpeed', 1)
+ rangeBySpeed = content.get('rangeBySpeed', 0)
+ vmeanBySpeed = content.get('vmeanBySpeed', 0)
+ vmaxBySpeed = content.get('vmaxBySpeed', 0)
+ pmeanBySpeed = content.get('pmeanBySpeed', 0)
+ pmaxBySpeed = content.get('pmaxBySpeed', 0)
+
+ numByPower = content.get('numByPower', 1)
+ rangeByPower = content.get('rangeByPower', 0)
+ vmeanByPower = content.get('vmeanByPower', 0)
+ vmaxByPower = content.get('vmaxByPower', 0)
+ pmeanByPower = content.get('pmeanByPower', 0)
+ pmaxByPower = content.get('pmaxByPower', 0)
+
+ #don't need, done on C#
+ #meanPowerBestRep = str(meanPowerBestRep).replace(',', '.')
ip = request.remote_addr
(con, cur) = connect_db()
- print("INSERT INTO results (personId, stationId, resistance, exerciseName, meanPowerBestRep,
repsAbove50pBest) VALUES (%s, %s, %s, %s, %s, %s)", (personId, stationId, resistance, exerciseName,
meanPowerBestRep, repsAbove50pBest))
- cur.execute("INSERT INTO results (personId, stationId, resistance, exerciseName, meanPowerBestRep,
repsAbove50pBest) VALUES (%s, %s, %s, %s, %s, %s)", (personId, stationId, resistance, exerciseName,
meanPowerBestRep, repsAbove50pBest))
+ cur.execute("INSERT INTO results " +
+ "(personId, stationId, resistance, exerciseName, " +
+ "numBySpeed, rangeBySpeed, vmeanBySpeed, vmaxBySpeed, pmeanBySpeed, pmaxBySpeed, " +
+ "numByPower, rangeByPower, vmeanByPower, vmaxByPower, pmeanByPower, pmaxByPower) " +
+ "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
+ (personId, stationId, resistance, exerciseName,
+ numBySpeed, rangeBySpeed, vmeanBySpeed, vmaxBySpeed, pmeanBySpeed, pmaxBySpeed,
+ numByPower, rangeByPower, vmeanByPower, vmaxByPower, pmeanByPower, pmaxByPower,
+ ))
con.commit()
return Response("", 202)
diff --git a/tables.txt b/tables.txt
index 6e7afde..6d2e25d 100644
--- a/tables.txt
+++ b/tables.txt
@@ -3,9 +3,11 @@
create database chronojump;
use chronojump;
-#this table is created just to test json
-
-CREATE TABLE results(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, dt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
personId INT, stationId INT, resistance FLOAT, exerciseName CHAR(30), meanPowerBestRep FLOAT,
repsAbove50pBest INT, comments CHAR(20));
+CREATE TABLE results (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, dt TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ personId INT, stationId INT, resistance FLOAT, exerciseName CHAR(30),
+ numBySpeed FLOAT, rangeBySpeed FLOAT, vmeanBySpeed FLOAT, vmaxBySpeed FLOAT, pmeanBySpeed
FLOAT, pmaxBySpeed FLOAT,
+ numByPower FLOAT, rangeByPower FLOAT, vmeanByPower FLOAT, vmaxByPower FLOAT, pmeanByPower
FLOAT, pmaxByPower FLOAT,
+ comments CHAR(20));
CREATE TABLE station(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name CHAR(30));
@@ -20,17 +22,26 @@ CREATE TABLE task(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, dt TIMESTAMP DEFAU
# 2.- insert sample data:
-insert into station VALUES(1, "Sprint");
-insert into station VALUES(2, "Multipower 1");
-insert into station VALUES(3, "Multipower 2");
-insert into station VALUES(4, "Press banca");
-insert into station VALUES(5, "Inercial 1");
-insert into station VALUES(6, "Inercial 2");
-insert into station VALUES(7, "Inercial 3");
-insert into station VALUES(8, "Dominades");
-insert into station VALUES(9, "Leg press");
-insert into person VALUES(NULL, "joan", 80, 175.7, "212,212,212,212", "");
-insert into person VALUES(NULL, "pep", 72, 164.4, "211,211,211,211", "");
-insert into results VALUES(NULL, NULL, 1, 2, 45.2, "press de banca", 480, 6, "");
-insert into results VALUES(NULL, NULL, 1, 1, 2, "sprint", NULL, NULL, "5 segons");
-insert into task VALUES(NULL, NULL, 1, "Mig squat amb 45 Kg, 3 series de 8 repeticions a 1,1 m/s.
Desplaçaments laterals amb la inercial de 800 W");
+INSERT INTO station VALUES(1, "Sprint");
+INSERT INTO station VALUES(2, "Multipower 1");
+INSERT INTO station VALUES(3, "Multipower 2");
+INSERT INTO station VALUES(4, "Press banca");
+INSERT INTO station VALUES(5, "Inercial 1");
+INSERT INTO station VALUES(6, "Inercial 2");
+INSERT INTO station VALUES(7, "Inercial 3");
+INSERT INTO station VALUES(8, "Dominades");
+INSERT INTO station VALUES(9, "Leg press");
+INSERT INTO person VALUES(NULL, "joan", 80, 175.7, "212,212,212,212", "");
+INSERT INTO person VALUES(NULL, "pep", 72, 164.4, "211,211,211,211", "");
+
+INSERT INTO results VALUES(NULL, NULL, 1, 2, 45.2, "press de banca",
+ 3, 60, 1.5, 2.1, 600.2, 800.3,
+ 4, 62, 1.4, 1.9, 620.4, 810.5,
+ "");
+INSERT INTO results VALUES(NULL, NULL, 1, 2, 45.2, "press de banca",
+ 2, 61, 1.6, 2.2, 500.2, 770.3,
+ 1, 64, 1.5, 2.0, 520.4, 790.5,
+ "");
+#INSERT INTO results VALUES(NULL, NULL, 1, 1, 2, "sprint", NULL, NULL, "5 segons");
+
+INSERT INTO task VALUES(NULL, NULL, 1, "Mig squat amb 45 Kg, 3 series de 8 repeticions a 1,1 m/s.
Desplaçaments laterals amb la inercial de 800 W");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]