From 4d260ab8e6e4f12a672b2899e739dec5790fd003 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Mon, 18 May 2020 20:02:09 +0200 Subject: [PATCH 1/2] adding strava logging to analyze errors --- rowers/tasks.py | 28 ++++++++++++++++++++++++++++ rowers/uploads.py | 10 ++++++++++ 2 files changed, 38 insertions(+) diff --git a/rowers/tasks.py b/rowers/tasks.py index d85afb51..b78a81bc 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -11,6 +11,7 @@ import gzip import shutil import numpy as np import re +import sys from scipy import optimize from scipy.signal import savgol_filter @@ -188,6 +189,15 @@ def handle_strava_sync(stravatoken,workoutid,filename,name,activity_type,descrip except TypeError: act = client.update_activity(res.id,activity_type=activity_type, description=description) + except: + e = sys.exc_info()[0] + t = time.localtime() + timestamp = time.strftime('%b-%d-%Y_%H%M', t) + with open('stravalog.log','a') as f: + f.write('\n') + f.write(timestamp) + f.write(str(e)) + result = update_workout_field_sql(workoutid,'uploadedtostrava',res.id,debug=debug) try: os.remove(filename) @@ -750,6 +760,24 @@ def handle_calctrimp(id, if np.isnan(hrtss): hrtss = 0 + if tss > 1000: + tss = 0 + + if trimp > 1000: + trimp = 0 + + if normp > 2000: + normp = 0 + + if normv > 2000: + normv = 0 + + if normw > 10000: + normw = 0 + + if hrtss > 1000: + hrtss = 0 + query = 'UPDATE rowers_workout SET rscore = {tss}, normp = {normp}, trimp={trimp}, hrtss={hrtss}, normv={normv}, normw={normw} WHERE id={id}'.format( tss = int(tss), diff --git a/rowers/uploads.py b/rowers/uploads.py index a694cd70..98b56eac 100644 --- a/rowers/uploads.py +++ b/rowers/uploads.py @@ -25,6 +25,7 @@ import yamllint from subprocess import call import re import sys +import time from verbalexpressions import VerEx @@ -551,6 +552,15 @@ def do_sync(w,options, quick=False): except NoTokenError: id = 0 message = "Please connect to Strava first" + except: + e = sys.exc_info()[0] + t = time.localtime() + timestamp = time.strftime('%b-%d-%Y_%H%M', t) + with open('stravalog.log','a') as f: + f.write('\n') + f.write(timestamp) + f.write(str(e)) + if ('upload_to_SportTracks' in options and options['upload_to_SportTracks']) or (w.user.sporttracks_auto_export and ispromember(w.user.user)): From c062d8c0da23fdc22bcd68f93e6142065ad9b67c Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 19 May 2020 08:03:30 +0200 Subject: [PATCH 2/2] race to challenge rename --- rowers/forms.py | 12 ++-- rowers/models.py | 22 +++---- .../templates/indoorvirtualeventcreate.html | 18 +++--- rowers/templates/menu_racing.html | 12 ++-- rowers/templates/racelist.html | 2 +- rowers/templates/virtualevent.html | 62 +++++++++---------- rowers/templates/virtualeventcreate.html | 20 +++--- rowers/templates/virtualevents.html | 14 ++--- rowers/views/racesviews.py | 34 +++++----- templates/newbase.html | 2 +- 10 files changed, 99 insertions(+), 99 deletions(-) diff --git a/rowers/forms.py b/rowers/forms.py index 98971e53..d0e78a23 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -373,7 +373,7 @@ class UploadOptionsForm(forms.Form): label='Make Workout Private') submitrace = forms.ModelChoiceField(queryset=VirtualRace.objects.all(), - label='Submit as Race Result', + label='Submit as challenge Result', required=False) landingpage = forms.ChoiceField(choices=nextpages, @@ -1382,11 +1382,11 @@ def get_countries(): class VirtualRaceSelectForm(forms.Form): regattatypechoices = ( - ('upcoming','Upcoming Races'), - ('ongoing','Ongoing Races'), - ('previous','Previous Races'), - ('my','My Races'), - ('all','All Races'), + ('upcoming','Upcoming Challenges'), + ('ongoing','Ongoing Challenges'), + ('previous','Previous Challenges'), + ('my','My Challenges'), + ('all','All Challenges'), ) regattatype = forms.ChoiceField( diff --git a/rowers/models.py b/rowers/models.py index f9f2b531..3d62dc69 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -2032,8 +2032,8 @@ class PlannedSession(models.Model): ('test','Mandatory Test'), ('cycletarget','Total for a time period'), ('coursetest','OTW test over a course'), - ('race','Virtual Race'), - ('indoorrace','Indoor Virtual Race'), + ('race','Virtual challenge'), + ('indoorrace','Indoor Virtual challenge'), ) regularsessiontypechoices = ( @@ -2197,8 +2197,8 @@ from django.core.validators import RegexValidator,validate_email registerchoices = ( - ('windowstart','Start of Race Window'), - ('windowend','End of Race Window'), + ('windowstart','Start of challenge Window'), + ('windowend','End of challenge Window'), ('deadline','Evaluation Closure Deadline'), ('manual','Manual - select below'), ) @@ -2239,7 +2239,7 @@ class VirtualRace(PlannedSession): startdate = self.startdate enddate = self.enddate - stri = u'Virtual Race {n}'.format( + stri = u'Virtual challenge {n}'.format( n = name, ) @@ -2505,11 +2505,11 @@ class IndoorVirtualRaceForm(ModelForm): if startdatetime > enddatetime: - raise forms.ValidationError("The Start of the Race Window should be before the End of the Race Window") + raise forms.ValidationError("The Start of the challenge Window should be before the End of the challenge Window") if cd['evaluation_closure'] <= enddatetime: - raise forms.ValidationError("Evaluation closure deadline should be after the Race Window closes") + raise forms.ValidationError("Evaluation closure deadline should be after the challenge Window closes") if cd['evaluation_closure'] <= timezone.now(): raise forms.ValidationError("Evaluation closure cannot be in the past") @@ -2626,11 +2626,11 @@ class VirtualRaceForm(ModelForm): if startdatetime > enddatetime: - raise forms.ValidationError("The Start of the Race Window should be before the End of the Race Window") + raise forms.ValidationError("The Start of the challenge Window should be before the End of the challenge Window") if cd['evaluation_closure'] <= enddatetime: - raise forms.ValidationError("Evaluation closure deadline should be after the Race Window closes") + raise forms.ValidationError("Evaluation closure deadline should be after the challenge Window closes") if cd['evaluation_closure'] <= timezone.now(): raise forms.ValidationError("Evaluation closure cannot be in the past") @@ -2924,7 +2924,7 @@ class VirtualRaceResult(models.Model): age = models.IntegerField(null=True) emailnotifications = models.BooleanField(default=True, - verbose_name = 'Receive race notifications by email') + verbose_name = 'Receive challenge notifications by email') def __str__(self): rr = Rower.objects.get(id=self.userid) @@ -2980,7 +2980,7 @@ class IndoorVirtualRaceResult(models.Model): age = models.IntegerField(null=True) emailnotifications = models.BooleanField(default=True, - verbose_name = 'Receive race notifications by email') + verbose_name = 'Receive challenge notifications by email') def __str__(self): rr = Rower.objects.get(id=self.userid) diff --git a/rowers/templates/indoorvirtualeventcreate.html b/rowers/templates/indoorvirtualeventcreate.html index 63095c09..2fcc477b 100644 --- a/rowers/templates/indoorvirtualeventcreate.html +++ b/rowers/templates/indoorvirtualeventcreate.html @@ -2,19 +2,19 @@ {% load staticfiles %} {% load rowerfilters %} -{% block title %}New Virtual Race{% endblock %} +{% block title %}New Virtual Challenge{% endblock %} {% block main %} -

New Indoor Virtual Race

+

New Indoor Virtual Challenge