Private
Public Access
1
0

fixing some C2 bike erg related stuff

This commit is contained in:
Sander Roosendaal
2020-08-30 21:21:25 +02:00
parent 24311aeeef
commit 668debceee
3 changed files with 27 additions and 3 deletions

View File

@@ -268,7 +268,8 @@ def c2wc(weightclass):
# Concept2 logbook sends over split data for each interval
# We use it here to generate a custom summary
# Some users complained about small differences
def summaryfromsplitdata(splitdata,data,filename,sep='|'):
def summaryfromsplitdata(splitdata,data,filename,sep='|',workouttype='rower'):
workouttype = workouttype.lower()
totaldist = data['distance']
totaltime = data['time']/10.
@@ -305,6 +306,11 @@ def summaryfromsplitdata(splitdata,data,filename,sep='|'):
velo = totaldist/totaltime
avgpower = 2.8*velo**(3.0)
if workouttype in ['bike','bikeerg']:
velo = velo/2.
avgpower = 2.8*velo**(3.0)
velo = velo*2
try:
restvelo = restdistance/resttime
@@ -312,6 +318,10 @@ def summaryfromsplitdata(splitdata,data,filename,sep='|'):
restvelo = 0
restpower = 2.8*restvelo**(3.0)
if workouttype in ['bike','bikeerg']:
restvelo = restvelo/2.
restpower = 2.8*restvelo**(3.0)
restvelo = restvelo*2
try:
avgdps = totaldist/data['stroke_count']
@@ -398,6 +408,8 @@ def summaryfromsplitdata(splitdata,data,filename,sep='|'):
if itime != 0:
ivelo = idist/itime
ipower = 2.8*ivelo**(3.0)
if workouttype in ['bike','bikeerg']:
ipower = 2.8*(ivelo/2.)**(3.0)
else:
ivelo = 0
ipower = 0
@@ -961,6 +973,7 @@ def add_workout_from_data(user,importid,data,strokedata,
thetimezone = 'UTC'
r = Rower.objects.get(user=user)
try:
rowdatetime = iso8601.parse_date(data['date_utc'])
except KeyError:
@@ -969,6 +982,7 @@ def add_workout_from_data(user,importid,data,strokedata,
rowdatetime = iso8601.parse_date(data['date'])
try:
c2intervaltype = data['workout_type']
@@ -1090,10 +1104,18 @@ def add_workout_from_data(user,importid,data,strokedata,
dosummary=True,dosmooth=False,
)
w = Workout.objects.get(id=id)
w.duration = dataprep.totaltime_sec_to_string(totaltime)
w.distance = totaldist
w.startdatetime = rowdatetime
w.starttime = rowdatetime.time()
w.date = rowdatetime.date()
w.save()
return id,message

View File

@@ -1129,7 +1129,7 @@ def create_row_df(r,distance,duration,startdatetime,workouttype='rower',
df = pd.DataFrame({
'TimeStamp (sec)': unixtime,
' Horizontal (meters)': d,
' Horizontal (meters)': d,
' Cadence (stokes/min)': spm,
' Stroke500mPace (sec/500m)':pace,
' ElapsedTime (sec)':elapsed,

View File

@@ -1651,6 +1651,8 @@ def workout_getimportview(request,externalid,source = 'c2'):
strokedata = res[1]
data = res[0]
workouttype = mytypes.c2mappinginv[data['type']]
# Now works only for C2
try:
@@ -1736,7 +1738,7 @@ def workout_getimportview(request,externalid,source = 'c2'):
# splitdata (only for C2)
if splitdata:
w.summary,sa,results = c2stuff.summaryfromsplitdata(splitdata,data,w.csvfilename)
w.summary,sa,results = c2stuff.summaryfromsplitdata(splitdata,data,w.csvfilename,workouttype=workouttype)
w.save()
from rowingdata.trainingparser import getlist