Private
Public Access
1
0

Merge branch 'release/v16.7.10'

This commit is contained in:
Sander Roosendaal
2021-12-02 20:32:43 +01:00
4 changed files with 51 additions and 5 deletions

View File

@@ -3194,7 +3194,7 @@ def df_from_summary(data):
spms = [0]
try:
hrs = [splits[0]['heart_rate']['average']]
except (KeyError, TypeError): # pragma: no cover
except (KeyError, TypeError, IndexError): # pragma: no cover
hrs = [0]
for split in splits:
@@ -3317,8 +3317,11 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone
df = df_from_summary(data)
else:
#dologging('debuglog.log',json.dumps(s.json()))
strokedata = pd.DataFrame.from_dict(s.json()['data'])
try:
strokedata = pd.DataFrame.from_dict(s.json()['data'])
except AttributeError:
dologging('debuglog.log','No stroke data in stroke data')
return 0
try:
res = make_cumvalues(0.1*strokedata['t'])

View File

@@ -29,6 +29,10 @@
{% if workouts %}
<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/nkimport/?selectallnew=true">Select All New</a>
<table width="70%" class="listtable">
<thead>
<tr>
@@ -44,7 +48,12 @@
{% for workout in workouts %}
<tr>
<td>
<a href="/rowers/workout/nkimport/{{ 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|lookuplong:'name' }}</td>
<td class="block" style="width:auto">{{ workout|lookuplong:'starttime' }}</td>
<td>{{ workout|lookup:'duration' }} </td>
@@ -55,6 +64,7 @@
{% endfor %}
</tbody>
</table>
</form>
</li>
{% else %}
<li class="grid_4">

View File

@@ -637,6 +637,35 @@ def workout_nkimport_view(request,userid=0,after=0,before=0):
workouts = workouts[::-1]
if request.method == 'POST':
try:
tdict = dict(request.POST.lists())
ids = tdict['workoutid']
nkids = [int(id) for id in ids]
alldata = {}
for item in res.json():
alldata[item['id']] = item
counter = 0
for nkid in nkids:
csvfilename = 'media/{code}_{nkid}.csv'.format(code=uuid4().hex[:16],nkid=nkid)
result = myqueue(
queue,
handle_nk_async_workout,
alldata,
r.user.id,
r.nktoken,
nkid,
counter,
r.defaulttimezone
)
counter = counter+1
messages.info(request,'Your NK logbook workouts will be imported in the background. It may take a few minutes before it appears.')
url = reverse('workouts_view')
return HttpResponseRedirect(url)
except KeyError:
pass
breadcrumbs = [
{
'url':'/rowers/list-workouts/',
@@ -648,6 +677,8 @@ def workout_nkimport_view(request,userid=0,after=0,before=0):
},
]
checknew = request.GET.get('selectallnew',False)
return render(request,'nk_list_import.html',
{
'workouts':workouts,
@@ -657,7 +688,8 @@ def workout_nkimport_view(request,userid=0,after=0,before=0):
'enddate':enddate,
'active':'nav-workouts',
'breadcrumbs':breadcrumbs,
'teams':get_my_teams(request.user)
'teams':get_my_teams(request.user),
'checknew':checknew,
})
# Process Strava Callback

View File

@@ -222,6 +222,7 @@ from rowers.tasks import (
handle_sendemail_ical,
handle_c2_async_workout,
handle_send_email_instantplan_notification,
handle_nk_async_workout,
)
from scipy.signal import savgol_filter