Prevent duplicate machines

This commit is contained in:
Arnaud Vergnet 2021-05-09 11:03:23 +02:00
parent 091bed7fa5
commit 33fd3a4668

View file

@ -181,16 +181,28 @@ def get_machine_remaining_time(row):
return time
def is_machine_parsed(dryers, washers, number):
for m in dryers:
if m["number"] == number:
return True
for m in washers:
if m["number"] == number:
return True
return False
def get_parsed_data(rows):
"""
Gets the parsed data from the web page, farmatting it in a easy to use object
Gets the parsed data from the web page, formatting it in a easy to use object
"""
dryers = []
washers = []
for row in rows:
machine_number = get_machine_number(row)
if not is_machine_parsed(dryers, washers, machine_number):
state = get_machine_state(row)
machine = {
"number": get_machine_number(row),
"number": machine_number,
"state": state.value,
"maxWeight": get_machine_weight(row),
"startTime": "",
@ -214,7 +226,6 @@ def get_parsed_data(rows):
dryers.append(machine)
else:
washers.append(machine)
return {
"dryers": dryers,
"washers": washers