[chronojump-server] Changed getEncoderExercise to getStationExercises



commit 62414fc8af7349eea21f793f7e5dfbef4462e58c
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Jul 10 23:29:43 2017 +0200

    Changed getEncoderExercise to getStationExercises

 main.py |   41 +++++++++++++++++++++++++++++++----------
 1 files changed, 31 insertions(+), 10 deletions(-)
---
diff --git a/main.py b/main.py
index 3bdd546..5c8d2a9 100755
--- a/main.py
+++ b/main.py
@@ -191,27 +191,48 @@ def getOtherStationsWithPendingTasks():
     else:
         return Response("", 202)
 
-@app.route("/getEncoderExercise", methods=['POST'])
+@app.route("/getStationExercises", methods=['POST'])
 @auto.doc()
-def getEncoderExercise():
-    """chronojump client sends exerciseID and exercise is returned (with -1 id if not found)"""
+def getStationExercises():
+    """chronojump client sends stationID and exercise list is returned"""
     content = request.get_json()
 
-    id  = content.get('exerciseId', "")
+    stationId  = content.get('stationId', "")
 
     (con, cur) = connect_db(cursorclass=MySQLdb.cursors.DictCursor)
 
-    cur.execute("SELECT * FROM exercise where id = %s", (id, ))
+    cur.execute("SELECT * FROM exercise where stationId = %s", (stationId, ))
     print(cur._last_executed)
-    exercise = cur.fetchall()
-    print(exercise)
+    exercises = cur.fetchall()
+    print(exercises)
 
-    if len(exercise) >= 1:
-        #assert len(exercise) >= 1
-        return Response(json.dumps(exercise[0]))
+    if len(exercises) >= 1:
+        assert len(exercises) >= 1
+        return Response(json.dumps(exercises))
     else:
         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("/uploadSprintData", methods=['POST'])
 @auto.doc()
 def uploadSprintData():


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]