diff --git a/.gitignore b/.gitignore index 9d0cde6..2040580 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /facebook/token -/washinsa/washinsa.json +/washinsa/washinsa_data.json /facebook/facebook_data.json /dashboard/dashboard_data.json /menu/menu_data.json diff --git a/__examples__/washinsa.json b/__examples__/washinsa_data.json similarity index 52% rename from __examples__/washinsa.json rename to __examples__/washinsa_data.json index 5d14ce7..be83635 100644 --- a/__examples__/washinsa.json +++ b/__examples__/washinsa_data.json @@ -2,101 +2,113 @@ "dryers": [ { "number": "1", - "state": "DISPONIBLE", - "startTime": "", - "endTime": "", "donePercent": "", + "startTime": "", + "state": 0, + "program": "", + "endTime": "", "remainingTime": "" }, { "number": "2", - "state": "EN COURS", - "startTime": "15:24", - "endTime": "15:59", - "donePercent": "62.9", - "remainingTime": "13" + "donePercent": "", + "startTime": "", + "state": 0, + "program": "", + "endTime": "", + "remainingTime": "" }, { "number": "3", - "state": "TERMINE", - "startTime": "", - "endTime": "", "donePercent": "", + "startTime": "", + "state": 0, + "program": "", + "endTime": "", "remainingTime": "" } ], "washers": [ { "number": "4", - "state": "EN COURS", - "startTime": "\u00a0", - "endTime": "\u00a0", - "donePercent": "", - "remainingTime": "0" + "donePercent": "68.9", + "startTime": "11:32", + "state": 1, + "program": "Couleurs 60\u00b0C & Lessive Automatique", + "endTime": "12:21", + "remainingTime": "15" }, { "number": "5", - "state": "EN COURS", - "startTime": "15:35", - "endTime": "16:15", - "donePercent": "26.9", - "remainingTime": "29" + "donePercent": "", + "startTime": "", + "state": 0, + "program": "", + "endTime": "", + "remainingTime": "" }, { "number": "6", - "state": "DISPONIBLE", - "startTime": "", - "endTime": "", "donePercent": "", + "startTime": "", + "state": 0, + "program": "", + "endTime": "", "remainingTime": "" }, { "number": "7", - "state": "EN COURS", - "startTime": "15:34", - "endTime": "16:19", - "donePercent": "26", - "remainingTime": "33" + "donePercent": "", + "startTime": "", + "state": 3, + "program": "", + "endTime": "", + "remainingTime": "" }, { "number": "8", - "state": "DISPONIBLE", - "startTime": "", - "endTime": "", "donePercent": "", + "startTime": "", + "state": 0, + "program": "", + "endTime": "", "remainingTime": "" }, { "number": "9", - "state": "DISPONIBLE", - "startTime": "", - "endTime": "", "donePercent": "", + "startTime": "", + "state": 0, + "program": "", + "endTime": "", "remainingTime": "" }, { "number": "10", - "state": "DISPONIBLE", - "startTime": "", - "endTime": "", - "donePercent": "", - "remainingTime": "" + "donePercent": "58.2", + "startTime": "11:39", + "state": 1, + "program": "Non repassable 40\u00b0C", + "endTime": "12:24", + "remainingTime": "19" }, { "number": "11", - "state": "DISPONIBLE", - "startTime": "", - "endTime": "", "donePercent": "", + "startTime": "", + "state": 0, + "program": "", + "endTime": "", "remainingTime": "" }, { "number": "12", - "state": "EN COURS", - "startTime": "15:02", - "endTime": "15:47", - "donePercent": "97.7", - "remainingTime": "1" + "donePercent": "", + "startTime": "", + "state": 4, + "program": "", + "endTime": "", + "remainingTime": "" } ] } \ No newline at end of file diff --git a/dashboard/dashboard_handler.py b/dashboard/dashboard_handler.py index 524b4c2..d180a00 100644 --- a/dashboard/dashboard_handler.py +++ b/dashboard/dashboard_handler.py @@ -3,7 +3,7 @@ from datetime import date import urllib.request import os.path -WASHINSA_FILE = '../washinsa/washinsa.json' +WASHINSA_FILE = '../washinsa/washinsa_data.json' MENU_FILE = '../menu/menu_data.json' FACEBOOK_FILE = '../facebook/facebook_data.json' @@ -56,10 +56,10 @@ def get_available_machines(): available_dryers = 0 available_washers = 0 for machine in data['dryers']: - if machine['state'] == 'DISPONIBLE': + if machine['state'] == 0: available_dryers += 1 for machine in data['washers']: - if machine['state'] == 'DISPONIBLE': + if machine['state'] == 0: available_washers += 1 except FileNotFoundError: print("Could not find " + WASHINSA_FILE)