From 2d46b36dc39cf4213b3f37de8565ed23db46d10f Mon Sep 17 00:00:00 2001 From: Lukas Metzger Date: Thu, 25 Jun 2020 14:27:06 +0200 Subject: Fix errors in sum calculation --- dash/pages/total.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'dash') diff --git a/dash/pages/total.py b/dash/pages/total.py index 130c7f2..9655c51 100644 --- a/dash/pages/total.py +++ b/dash/pages/total.py @@ -271,7 +271,7 @@ def make_sums(rangeStart, rangeEnd, satellites): if len(satellites) > 0: formatStrings = ','.join(['%s'] * len(satellites)) - cursor.execute(stmt + ' AND r.ip IN ({})'.format(formatStrings), tuple([days, rangeStart, rangeEnd] + satellites)) + cursor.execute(stmt + ' AND r.ip IN ({})'.format(formatStrings), tuple([rangeStart, rangeEnd] + satellites)) else: cursor.execute(stmt, (rangeStart, rangeEnd)) @@ -279,12 +279,19 @@ def make_sums(rangeStart, rangeEnd, satellites): db.closeConnection(dbcon) - strTimes = 'Total Time: {}h Total Session Time: {}h Total Off Time: {}h'.format( - int(data['totalTime'] / 3600), - int(data['totalSessionTime'] / 3600), - int(data['totalOffTime'] / 3600) - ) - strSessions = 'Total Short Sessions: {} Total Long Sessions: {}'.format(data['shortSessions'], data['longSessions']) + try: + strTimes = 'Total Time: {}h Total Session Time: {}h Total Off Time: {}h'.format( + int(data['totalTime'] / 3600), + int(data['totalSessionTime'] / 3600), + int(data['totalOffTime'] / 3600) + ) + except: + strTimes = "No Data available!" + + try: + strSessions = 'Total Short Sessions: {} Total Long Sessions: {}'.format(data['shortSessions'], data['longSessions']) + except: + strSessions = "No Data available!" return strTimes, strSessions -- cgit v1.2.3-55-g7522