Commit 6a14b698 authored by Kristian Tan's avatar Kristian Tan

refactor

parent 07b88ae6
...@@ -73,11 +73,12 @@ def create_entry(change_pin): ...@@ -73,11 +73,12 @@ def create_entry(change_pin):
pins[change_pin]['on_time'] = None pins[change_pin]['on_time'] = None
pins[change_pin]['on_date'] = None pins[change_pin]['on_date'] = None
max = 0
labels = []
values = []
def generate_graph_data(): def generate_graph_data():
labels = []
values = []
max = 0
# Create data for chart # Create data for chart
count = 0 count = 0
records = DailyUsage.query.order_by(asc(DailyUsage.date)).all() records = DailyUsage.query.order_by(asc(DailyUsage.date)).all()
...@@ -89,6 +90,7 @@ def generate_graph_data(): ...@@ -89,6 +90,7 @@ def generate_graph_data():
count += 1 count += 1
if count >= 7: if count >= 7:
break break
return labels, values, max
db.create_all() db.create_all()
...@@ -110,7 +112,7 @@ for pin in pins: ...@@ -110,7 +112,7 @@ for pin in pins:
GPIO.output(pin, GPIO.LOW) GPIO.output(pin, GPIO.LOW)
generate_graph_data() labels, values, max = generate_graph_data()
# Create data for chart # Create data for chart
# count = 0 # count = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment