[chronojump-server] implemented getOtherStationsWithPendingTasks



commit 77790dfbc4efa9f312bc7daf30b82684a39b628a
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sun Jul 9 20:30:39 2017 +0200

    implemented getOtherStationsWithPendingTasks

 main.py |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/main.py b/main.py
index 1f483d9..3bdd546 100755
--- a/main.py
+++ b/main.py
@@ -170,6 +170,27 @@ def updateTask():
 
     return Response("", 202)
 
+@app.route("/getOtherStationsWithPendingTasks", methods=['POST'])
+@auto.doc()
+def getOtherStationsWithPendingTasks():
+    """chronojump client sends personId and returned value are station names where there are pending tasks 
expect stationId (current)"""
+    content = request.get_json()
+
+    personId  = content.get('personId', "")
+    stationId  = content.get('stationId', "")
+
+    (con, cur) = connect_db(cursorclass=MySQLdb.cursors.DictCursor)
+
+    cur.execute("SELECT station.name AS stationName, count(*) AS tasksCount FROM station,task WHERE 
task.personId = %s AND task.stationId != %s AND task.done = 0 AND station.id = task.stationId GROUP BY 
stationName", (personId, stationId))
+
+    print(cur._last_executed)
+    stations = cur.fetchall()
+
+    if len(stations) >= 1:
+        return Response(json.dumps(stations))
+    else:
+        return Response("", 202)
+
 @app.route("/getEncoderExercise", methods=['POST'])
 @auto.doc()
 def getEncoderExercise():


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