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

query by not all

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