From dfdaa566a04aa33fb091c208466e25362983118b Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 4 May 2024 11:31:25 +0200 Subject: [PATCH] fixed alerts, manual testing completed --- rowers/alerts.py | 7 ++++--- rowers/dataroutines.py | 15 +++++++-------- rowers/interactiveplots.py | 2 ++ rowers/plannedsessions.py | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/rowers/alerts.py b/rowers/alerts.py index bf3587bd..2beeca2e 100644 --- a/rowers/alerts.py +++ b/rowers/alerts.py @@ -101,9 +101,10 @@ def alert_get_stats(alert, nperiod=0): # pragma: no cover ids = [w.id for w in workouts] try: - df = read_data(columns, ids=ids, doclean=True, - workstrokesonly=workstrokesonly) - df = remove_nulls_pl(df) + df = getsmallrowdata_pd(columns, ids=ids, doclean=True, + workstrokesonly=workstrokesonly) + df.dropna(axis=1,how='all',inplace=True) + df.dropna(axis=0,how='all',inplace=True) except: return { 'workouts': workouts.count(), diff --git a/rowers/dataroutines.py b/rowers/dataroutines.py index cc433e31..b08fc1a7 100644 --- a/rowers/dataroutines.py +++ b/rowers/dataroutines.py @@ -231,7 +231,6 @@ def get_video_data(w, groups=['basic'], mode='water'): df2 = df2.round(decimals=2) - boatspeed = (100*df2['velo']).astype(int)/100. try: coordinates = get_latlon_time(w.id) @@ -245,10 +244,13 @@ def get_video_data(w, groups=['basic'], mode='water'): coordinates.set_index(pd.to_timedelta( coordinates['time'], unit='s'), inplace=True) - coordinates = coordinates.resample('1s').mean().interpolate() - coordinates['time'] = coordinates['time']-coordinates['time'].min() - latitude = coordinates['latitude'] - longitude = coordinates['longitude'] + coordinates = coordinates.resample('1s').first().interpolate().fillna(method='ffill') + #coordinates['time'] = coordinates['time']-coordinates['time'].min() + df2 = pd.concat([df2, coordinates], axis=1) + latitude = df2['latitude'] + longitude = df2['longitude'] + boatspeed = (100*df2['velo']).astype(int)/100. + # bundle data data = { 'boatspeed': boatspeed.values.tolist(), @@ -281,9 +283,6 @@ def get_video_data(w, groups=['basic'], mode='water'): except KeyError: # pragma: no cover pass - for key, value in data.items(): - print(key, len(value)) - metrics['boatspeed'] = metrics.pop('velo') # metrics['workperstroke'] = metrics.pop('driveenergy') metrics = collections.OrderedDict(sorted(metrics.items())) diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index b7156e66..65fd28ed 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -365,6 +365,8 @@ def interactive_planchart(data, startdate, enddate): 'data': data_dict, } + print(data_dict) + script, div = get_chart("/plan", chart_data, debug=False) return script, div diff --git a/rowers/plannedsessions.py b/rowers/plannedsessions.py index 7f23e078..c8ca0ab2 100644 --- a/rowers/plannedsessions.py +++ b/rowers/plannedsessions.py @@ -281,7 +281,7 @@ def get_execution_report(rower, startdate, enddate, plan=None): else: plannedscore += 60 actualscore += 0 - elif w.hrtss != 0: + elif w.hrtss >= 0: if ratio > 0: plannedscore += w.hrtss/ratio actualscore += w.hrtss