Commit 86e3f733 authored by Kristian Tan's avatar Kristian Tan

test

parent 850ebaa4
......@@ -4,7 +4,7 @@ from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import asc, desc
import os
from datetime import datetime, date, timedelta
from services.daily_usage_service import DailyUsageService
from services.daily_usage_service import test
# from daily_usage import DailyUsage
app = Flask(__name__)
......@@ -100,7 +100,7 @@ db.create_all()
daily_total = get_todays_usage()
todays_cost = get_todays_cost()
print(get_todays_usage())
print(DailyUsageService.get_todays_usage())
print(test.get_todays_usage())
print(get_todays_cost())
# Create dictionary to store pin info
......
......@@ -19,3 +19,13 @@ class DailyUsageService:
if latest_entry_date == datetime.today().date():
return format(latest_entry.kwhUsed, '.7f')
return 0
class test:
def get_todays_usage(self):
latest_entry = DailyUsage.query.order_by(desc(DailyUsage.date)).first()
# latest_entry = db.session.query(DailyUsage).order_by(DailyUsage.date.asc()).first()
if latest_entry:
latest_entry_date = date(latest_entry.date.year, latest_entry.date.month, latest_entry.date.day)
if latest_entry_date == datetime.today().date():
return format(latest_entry.kwhUsed, '.7f')
return 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