From a98c00adf60b493482ab925bf42c704642bb3a68 Mon Sep 17 00:00:00 2001 From: Bouke Scheltinga Date: Mon, 30 Oct 2023 12:04:29 +0100 Subject: [PATCH 1/2] Add max value to intensity goal --- sensor_api/sensorapi/connector.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sensor_api/sensorapi/connector.py b/sensor_api/sensorapi/connector.py index aaa8b209..48c2d614 100644 --- a/sensor_api/sensorapi/connector.py +++ b/sensor_api/sensorapi/connector.py @@ -30,6 +30,7 @@ MAX_VALUE_STEP_GOAL = 10000 TOKEN_HEADER = 'X-PerfectFit-Auth-Token' PA_LAPSE_MODERATION = 0.95 +MAX_VALUE_INTENSITY_GOAL = 150 # functions for sensors data querying @@ -143,6 +144,9 @@ def get_intensity_minutes_data(user_id: int, for hour in res_json: intensity_minutes += sum(val > HR_INTENSITY_THRESHOLD for val in hour['values']) + if intensity_minutes > MAX_VALUE_INTENSITY_GOAL: + return MAX_VALUE_INTENSITY_GOAL + return intensity_minutes except ValueError: From 1553b71fb90dd074fb87337d5918d2bba9bdcf27 Mon Sep 17 00:00:00 2001 From: bscheltinga <45515920+bscheltinga@users.noreply.github.com> Date: Wed, 1 Nov 2023 12:05:16 +0100 Subject: [PATCH 2/2] Update sensor_api/sensorapi/connector.py Co-authored-by: Walter Baccinelli <100706999+wbaccinelli@users.noreply.github.com> --- sensor_api/sensorapi/connector.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sensor_api/sensorapi/connector.py b/sensor_api/sensorapi/connector.py index 48c2d614..a22be823 100644 --- a/sensor_api/sensorapi/connector.py +++ b/sensor_api/sensorapi/connector.py @@ -144,10 +144,8 @@ def get_intensity_minutes_data(user_id: int, for hour in res_json: intensity_minutes += sum(val > HR_INTENSITY_THRESHOLD for val in hour['values']) - if intensity_minutes > MAX_VALUE_INTENSITY_GOAL: - return MAX_VALUE_INTENSITY_GOAL + return min(intensity_minutes, MAX_VALUE_INTENSITY_GOAL) - return intensity_minutes except ValueError: logging.error(f"Error in returned value from sensors: '{res}'")