From 8d8e12315e78b1722a4a4eca33541bcd05d3b130 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 24 Oct 2022 21:03:15 +0200 Subject: [PATCH] fix date sorting strava --- rowers/interactiveplots.py | 15 +++++++++++++-- rowers/management/commands/processalerts.py | 9 +++++++-- rowers/views/importviews.py | 3 +++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index cdf5060a..1bb56563 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -4082,6 +4082,9 @@ def instroke_multi_interactive_chart(selected): df_plot = pd.DataFrame() ids = [analysis.id for analysis in selected] metrics = list(set([analysis.metric for analysis in selected])) + maximum_values = {} + for metric in metrics: + maximum_values[metric] = 0 for analysis in selected: #start_second, end_second, spm_min, spm_max, name activeminutesmin = int(analysis.start_second/60.) @@ -4095,14 +4098,22 @@ def instroke_multi_interactive_chart(selected): activeminutesmax=activeminutesmax, ) mean_vals = data.mean() - if len(metrics)>1: - mean_vals = mean_vals/mean_vals.max() + if analysis.metric == 'boat accelerator curve': + mean_vals[0] = (mean_vals[1]+ mean_vals[len(mean_vals)-1])/2. + if len(metrics) > 1: + if mean_vals.max() > maximum_values[analysis.metric]: + maximum_values[analysis.metric] = mean_vals.max() xvals = np.arange(len(mean_vals)) xname = 'x_'+str(analysis.id) yname = 'y_'+str(analysis.id) df_plot[xname] = xvals df_plot[yname] = mean_vals + if len(metrics) > 1: + for analysis in selected: + yname = 'y_'+str(analysis.id) + df_plot[yname] = df_plot[yname] / maximum_values[analysis.metric] + source = ColumnDataSource( df_plot ) diff --git a/rowers/management/commands/processalerts.py b/rowers/management/commands/processalerts.py index 04ca937c..d63de7c2 100644 --- a/rowers/management/commands/processalerts.py +++ b/rowers/management/commands/processalerts.py @@ -9,7 +9,7 @@ from rowers.tasks import handle_send_email_alert from rowers import alerts -from rowers.utils import myqueue +from rowers.utils import myqueue, dologging import datetime @@ -38,7 +38,7 @@ class Command(BaseCommand): testing = False todaysalerts = Alert.objects.filter( - next_run__lt=datetime.date.today(), emailalert=True) + next_run__lte=datetime.date.today(), emailalert=True) for alert in todaysalerts: stats = alerts.alert_get_stats(alert) @@ -57,6 +57,11 @@ class Command(BaseCommand): stats, debug=True, othertexts=othertexts) + dologging('alerts.log', 'Sent alert {id} to {email}'.format( + id = alert.id, + email = alert.manager.email, + )) + # advance next_run if not testing: alert.next_run = datetime.date.today() + datetime.timedelta(days=alert.period-1) diff --git a/rowers/views/importviews.py b/rowers/views/importviews.py index ab767784..0dea2569 100644 --- a/rowers/views/importviews.py +++ b/rowers/views/importviews.py @@ -1289,6 +1289,9 @@ def workout_stravaimport_view(request, message="", userid=0): checknew = request.GET.get('selectallnew', False) + # 2022-10-24 sorting the results + workouts = sorted(workouts, key = lambda d:d['starttime'], reverse=True) + return render(request, 'strava_list_import.html', {'workouts': workouts, 'rower': rower,