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

test

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