Private
Public Access
1
0

Merge branch 'release/v16.4.27'

This commit is contained in:
Sander Roosendaal
2021-08-26 08:36:41 +02:00
5 changed files with 60 additions and 12 deletions

View File

@@ -2153,8 +2153,12 @@ def interactive_histoall(theworkouts,histoparam,includereststrokes,
# throw out nans
histopwr = histopwr[~np.isinf(histopwr)]
histopwr = histopwr[histopwr > yaxminima[histoparam]]
histopwr = histopwr[histopwr < yaxmaxima[histoparam]]
if histoparam == 'catch':
histopwr = histopwr[histopwr < yaxminima[histoparam]]
histopwr = histopwr[histopwr > yaxmaxima[histoparam]]
else:
histopwr = histopwr[histopwr > yaxminima[histoparam]]
histopwr = histopwr[histopwr < yaxmaxima[histoparam]]
plot = Figure(tools=TOOLS,plot_width=900,
toolbar_sticky=False,

View File

@@ -307,9 +307,10 @@ class Command(BaseCommand):
message.delete()
# Strava
#rowers = Rower.objects.filter(strava_auto_import=True)
#for r in rowers:
# stravastuff.get_strava_workouts(r)
rowers = Rower.objects.filter(strava_auto_import=True)
for r in rowers:
if user_is_not_basic(r.user):
stravastuff.get_strava_workouts(r)
self.stdout.write(self.style.SUCCESS(
'Successfully processed email attachments'))

View File

@@ -18,6 +18,10 @@
</li>
<li class="grid_4">
<form enctype="multipart/form-data" method="post">
{% csrf_token %}
<input name='workouts' type="submit" value="Import selected workouts">
<a href="/rowers/workout/stravaimport/?selectallnew=true">Select All New</a>
<table width="70%" class="listtable">
<thead>
<tr>
@@ -34,7 +38,12 @@
{% for workout in workouts %}
<tr>
<td>
<a href="/rowers/workout/stravaimport/{{ workout|lookup:'id' }}/async/">Import</a></td>
{% if workout|lookup:'new' == 'NEW' and checknew == 'true' %}
<input checked type="checkbox" value={{ workout|lookup:'id' }} name="workoutid">
{% else %}
<input type="checkbox" value={{ workout|lookup:'id' }} name="workoutid">
{% endif %}
</td>
<td>{{ workout|lookup:'name' }}</td>
<td>{{ workout|lookup:'starttime' }}</td>
<td>{{ workout|lookup:'duration' }} </td>
@@ -46,6 +55,7 @@
{% endfor %}
</tbody>
</table>
</form>
</li>
</ul>
{% else %}

View File

@@ -5,6 +5,7 @@ from __future__ import unicode_literals
from rowers.views.statements import *
from rowers.plannedsessions import get_dates_timeperiod
from rowers.tasks import fetch_strava_workout
import numpy
@@ -923,6 +924,7 @@ def workout_rp3import_view(request,userid=0):
@permission_required('rower.is_coach',fn=get_user_by_userid,raise_exception=True)
@permission_required('rower.is_not_freecoach',fn=get_user_by_userid, raise_exception=True)
def workout_stravaimport_view(request,message="",userid=0):
r = getrequestrower(request,userid=userid)
if r.user != request.user:
messages.error(request,'You can only access your own workouts on the NK Logbook, not those of your athletes')
@@ -939,6 +941,7 @@ def workout_stravaimport_view(request,message="",userid=0):
res = stravastuff.get_strava_workout_list(request.user)
if (res.status_code != 200): # pragma: no cover
if (res.status_code == 401):
r = getrower(request.user)
@@ -952,6 +955,7 @@ def workout_stravaimport_view(request,message="",userid=0):
else:
workouts = []
r = getrower(request.user)
rower = r
stravaids = [int(item['id']) for item in res.json()]
stravadata = [{
'id':int(item['id']),
@@ -995,8 +999,34 @@ def workout_stravaimport_view(request,message="",userid=0):
r = item['type']
keys = ['id','distance','duration','starttime','type','name','new']
values = [i,d,ttot,s,r,n,nnn]
res = dict(zip(keys,values))
workouts.append(res)
res2 = dict(zip(keys,values))
workouts.append(res2)
if request.method == "POST":
try:
tdict = dict(request.POST.lists())
ids = tdict['workoutid']
stravaids = [int(id) for id in ids]
alldata = {}
for item in res.json():
alldata[item['id']] = item
for stravaid in stravaids:
csvfilename = 'media/{code}_{stravaid}.csv'.format(code=uuid4().hex[:16],stravaid=stravaid)
result = myqueue(
queue,
fetch_strava_workout,
rower.stravatoken,
stravastuff.oauth_data,
stravaid,
csvfilename,
rower.user.id
)
# done, redirect to workouts list
messages.info(request,'Your Strava workouts will be imported in the background. It may take a few minutes before it appears.'.format(stravaid=stravaid))
url = reverse('workouts_view')
return HttpResponseRedirect(url)
except KeyError:
pass
breadcrumbs = [
{
@@ -1009,15 +1039,15 @@ def workout_stravaimport_view(request,message="",userid=0):
},
]
r = getrower(request.user)
checknew = request.GET.get('selectallnew',False)
return render(request,'strava_list_import.html',
{'workouts':workouts,
'rower':r,
'rower':rower,
'active':'nav-workouts',
'breadcrumbs':breadcrumbs,
'teams':get_my_teams(request.user),
'checknew':checknew,
})
return HttpResponse(res) # pragma: no cover

View File

@@ -3502,7 +3502,10 @@ def workout_stats_view(request,id=0,message="",successmessage=""):
hrdrift = ((pwr1/hr1)-(pwr2/hr2))/(pwr1/hr1)
hrdrift *= 100.
if not np.isnan(hrdrift):
hrdrift = int(100*hrdrift)/100.
try:
hrdrift = int(100*hrdrift)/100.
except:
hrdrift = 0
otherstats['hrdrift'] = {
'verbose_name': 'Heart Rate Drift',
'value': hrdrift,