diff options
| author | Anson Bridges <bridges.anson@gmail.com> | 2024-11-14 01:20:05 -0500 |
|---|---|---|
| committer | Anson Bridges <bridges.anson@gmail.com> | 2024-11-14 01:20:05 -0500 |
| commit | 3f68ac783948c7d47974993854a1d317399d3b04 (patch) | |
| tree | b4c5413f54a5435b279977ba6835581bb4f36567 /dashboard_website/dashboard.py | |
| parent | 5d013db5968b4b1989a5b2eabf2ad651540240d9 (diff) | |
bug fixes from server testing, route previews, slight routing improvements
Diffstat (limited to 'dashboard_website/dashboard.py')
| -rw-r--r-- | dashboard_website/dashboard.py | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/dashboard_website/dashboard.py b/dashboard_website/dashboard.py index 77832aa..757324d 100644 --- a/dashboard_website/dashboard.py +++ b/dashboard_website/dashboard.py @@ -73,16 +73,18 @@ def requestRoute(): if not ( (type(content['longitude']) is float ) and (type(content['latitude']) is float)): return jsonify({'status' : "ERROR 2"}) - + + bike, clue = db.getBikeCluePair(content['team_index']) + if clue == None: # bike disabled or without clue -- should not ping bike yet + return jsonify({'status' : "ERROR 5"}) + if db.pingBike(content['team_index'], content['latitude'], content['longitude']) == 4: return jsonify({'status' : "ERROR 4"}) if db.currently_updating: return jsonify({'status' : "ERROR 3"}) - bike, clue = db.getBikeCluePair(content['team_index']) - if clue == None: - return jsonify({'status' : "ERROR 5"}) + route = router.getRouteFullJSON(bike, clue) if route['code'] != 'Ok': # or some other code indicating routing problem? @@ -257,6 +259,7 @@ def getLatestInfo(): 'clues_changed' : False, 'home_changed' : False, 'routes_changed' : False, + 'routes_to_commit' : db.routesToCommit, 'route_update_staged' : db.is_route_update_required() } cl = db.getCluesJSON(last_timestamp) if cl != False: @@ -266,10 +269,11 @@ def getLatestInfo(): if h != False: data['home_changed'] = True data['homebase'] = h - r = db.getRoutesJSON(last_timestamp) - if r != False: + p, r = db.getRoutesJSON(last_timestamp) + if p != False: data['routes_changed'] = True data['routes'] = r + data['preview_routes'] = p data['calculating_routes'] = db.currently_updating data['bikes'] = db.getBikesJSON() data['status'] = "OK" @@ -328,7 +332,15 @@ def siteControls(): elif cmd == "generateRoutes": if db.updateRoutes() != 0: return jsonify({"status" : "ERROR"}) - return jsonify({"status" : "OK"}) + return jsonify({"status" : "OK"}) + elif cmd == "stopGenerating": + db.force_stop() + return jsonify({"status" : "OK"}) + elif cmd == "commitRoutes": + if db.routesToCommit: + db.applyPreviewRoutes() + return jsonify({"status" : "OK"}) + return render_template("controls.html") |
