summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Metzger2020-06-25 14:27:06 +0200
committerLukas Metzger2020-06-25 14:27:06 +0200
commit2d46b36dc39cf4213b3f37de8565ed23db46d10f (patch)
tree9f3c99725505a6d080e733abe5630b47ac71e615
parentFixes for sattelites (diff)
downloadbwlp-statistics-2d46b36dc39cf4213b3f37de8565ed23db46d10f.tar.gz
bwlp-statistics-2d46b36dc39cf4213b3f37de8565ed23db46d10f.tar.xz
bwlp-statistics-2d46b36dc39cf4213b3f37de8565ed23db46d10f.zip
Fix errors in sum calculation
-rw-r--r--dash/pages/total.py21
1 files changed, 14 insertions, 7 deletions
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