Commit 1521640a authored by Kristian Tan's avatar Kristian Tan

query by not all

parent 9d956baa
......@@ -33,6 +33,7 @@ class DailyUsage(db.Model):
db.create_all()
DailyUsage.query().delete()
# Create dictionary to store pin info
pins = {
......@@ -61,7 +62,7 @@ def main():
@app.route("/<change_pin>")
def toggle_pin(change_pin):
# TODO: change_pin is somethimes favicon.co for some reason? Fix
# TODO: change_pin is sometimes favicon.co for some reason? Fix
if change_pin == 'favicon.ico':
pass
......@@ -76,16 +77,19 @@ def toggle_pin(change_pin):
message += " off."
if pins[change_pin]['on_time'] is not None:
uptime = str(datetime.now() - pins[change_pin]['on_time'])
d = DailyUsage(date=pins[change_pin]['on_time'], hours=uptime)
print("===========")
print("UPTIME STRING: " + uptime)
print("DAILYUSAGE: " + d)
print("===========")
d = DailyUsage(date=pins[change_pin]['on_time'], hours=uptime)
db.session.add(d)
db.session.commit()
pins[change_pin]['on_time'] = None
print("==========")
d = DailyUsage.query.filter_by(id=1)
print(d)
e = DailyUsage.query.filter_by(id=1)
print("DB ENTRY: " + e)
print("==========")
else:
message += " on."
......
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