From 34b1bcd4f9e294bf37854ecc3d96c4c1ddc654c1 Mon Sep 17 00:00:00 2001 From: Eduardo Spremolla Date: Fri, 14 Aug 2020 11:00:24 -0300 Subject: [PATCH] Update endpoints.py Only plot one point per minute to unclutter several days fermentation charts. --- modules/logs/endpoints.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/logs/endpoints.py b/modules/logs/endpoints.py index d787ea9d..569ad0ea 100644 --- a/modules/logs/endpoints.py +++ b/modules/logs/endpoints.py @@ -87,15 +87,17 @@ def read_log_as_json(self, log_type, log_id): # pylint: disable=no-self-use array = [] with open(filename, 'r', encoding='utf-8') as csv_file: reader = csv.reader(csv_file) + l_time=0 for row in reader: try: - array.append([ - int((datetime.datetime.strptime( - row[0], "%Y-%m-%d %H:%M:%S") - - datetime.datetime(1970, 1, 1)).total_seconds()) * - 1000, - float(row[1]) - ]) + p_time=int((datetime.datetime.strptime( # get point timestamp + row[0], "%Y-%m-%d %H:%M:%S") - + datetime.datetime(1970, 1, 1)).total_seconds()) * 1000 + if ( abs(float(row[1])) < 110 ) and # filter invalid points + ( p_time >= l_time ): # only plot if more than 60 sec from previus point + l_time = p_time + 60000; + array.append([p_time , float(row[1])]) + except IndexError: pass return array