[chronojump-server] EncoderExercise can be downloaded
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump-server] EncoderExercise can be downloaded
- Date: Wed, 28 Jun 2017 19:07:20 +0000 (UTC)
commit 8f8ad67dfbb68d97e56aa0c4a666ad0a038af786
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Jun 28 21:06:57 2017 +0200
EncoderExercise can be downloaded
main.py | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/main.py b/main.py
index b32cab7..be68664 100755
--- a/main.py
+++ b/main.py
@@ -134,7 +134,7 @@ def getTasks():
(con, cur) = connect_db(cursorclass=MySQLdb.cursors.DictCursor)
#select everything exept datetime because is not serializable
- cur.execute("SELECT task.id, task.type, task.personId, task.stationId, task.exerciseId, task.sets,
task.nreps, task.load, task.speed, task.percentMaxSpeed, task.laterality, task.comment, task.done FROM task,
person WHERE person.id = %s AND person.id = task.personId AND task.stationId = %s AND done = 0", (personId,
stationId))
+ cur.execute("SELECT task.id, task.type, task.personId, task.stationId, task.exerciseId, exercise.name AS
exerciseName, task.sets, task.nreps, task.load, task.speed, task.percentMaxSpeed, task.laterality,
task.comment, task.done FROM task, exercise, person WHERE task.exerciseId = exercise.id AND person.id = %s
AND person.id = task.personId AND task.stationId = %s AND done = 0", (personId, stationId))
print(cur._last_executed)
tasks = cur.fetchall()
@@ -170,6 +170,27 @@ def updateTask():
return Response("", 202)
+@app.route("/getEncoderExercise", methods=['POST'])
+@auto.doc()
+def getEncoderExercise():
+ """chronojump client sends exerciseID and exercise is returned (with -1 id if not found)"""
+ content = request.get_json()
+
+ id = content.get('exerciseId', "")
+
+ (con, cur) = connect_db(cursorclass=MySQLdb.cursors.DictCursor)
+
+ cur.execute("SELECT * FROM exercise where id = %s", (id, ))
+ print(cur._last_executed)
+ exercise = cur.fetchall()
+ print(exercise)
+
+ if len(exercise) >= 1:
+ #assert len(exercise) >= 1
+ return Response(json.dumps(exercise[0]))
+ else:
+ return Response("", 202)
+
@app.route("/uploadEncoderData", methods=['POST'])
@auto.doc()
def uploadEncoderData():
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]