From e4c5cea55a957990f0338a4f51d3662d444ef6d7 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Tue, 21 Nov 2017 09:26:58 +0100 Subject: [PATCH] fix: prevent out of bound time span. (Happend because the hole day is considered, 24*7 < 7days + remaining hours of the day) --- users_helper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/users_helper.py b/users_helper.py index 18942b3..badf901 100644 --- a/users_helper.py +++ b/users_helper.py @@ -146,7 +146,10 @@ class Users_helper: for timestamp in timestamps: # sum occurence during the current hour dateTimestamp = datetime.datetime.fromtimestamp(float(timestamp)) dateTimestamp = dateTimestamp.replace(minute=0, second=0, microsecond=0) - dico_hours[util.getTimestamp(dateTimestamp)] += 1 + try: + dico_hours[util.getTimestamp(dateTimestamp)] += 1 + except KeyError: # timestamp out of bound (greater than 1 week) + pass # Format data data = []