From daa6ec876cb9c5e5611b1b98ba4f148372ebb1e6 Mon Sep 17 00:00:00 2001 From: Alexander Munch-Hansen Date: Sat, 6 Apr 2019 18:01:50 +0200 Subject: [PATCH] more bug fixing --- server/nightr/strategies/tide_strat.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/nightr/strategies/tide_strat.py b/server/nightr/strategies/tide_strat.py index b6f1355..2b48c4f 100644 --- a/server/nightr/strategies/tide_strat.py +++ b/server/nightr/strategies/tide_strat.py @@ -33,7 +33,7 @@ def is_tide(context: Context) -> Prediction: matches = [[x[0], int(x[1])] for x in lel if x[0].month == month] all_the_data = requests.get('https://www.dmi.dk/NinJo2DmiDk/ninjo2dmidk?cmd=odj&stations=22331&datatype=obs') - current_water_level = json.loads(all_the_data.content)[0]['values'][-1]['value'] + current_water_level = int(json.loads(all_the_data.content)[0]['values'][-1]['value']) # Generate average of when the water is high last_match = matches[0] @@ -50,6 +50,7 @@ def is_tide(context: Context) -> Prediction: if last_match[1] < 0 and last_match[1] < current_water_level: # Increasing time = last_match while time[1] != current_water_level: + time[0] += average_delta time[1] += 1 @@ -62,12 +63,14 @@ def is_tide(context: Context) -> Prediction: elif last_match[1] > 0 and last_match[1] > current_water_level: # Decreasing time = last_match while time[1] != current_water_level: + time[0] += average_delta time[1] -= 1 elif last_match[1] > 0 and last_match[1] < current_water_level: time = last_match while time[1] != current_water_level: + time[0] += average_delta time[1] += 1