Private
Public Access
1
0

api v3 latency related improvements

This commit is contained in:
Sander Roosendaal
2023-01-21 10:00:26 +01:00
parent 7ccebc7a98
commit b02a2075c6
5 changed files with 87 additions and 32 deletions

View File

@@ -1047,6 +1047,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
forceunit='lbs',
consistencychecks=False,
startdatetime='',
workoutid='',
impeller=False):
message = None
@@ -1089,7 +1090,8 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
return new_workout_from_df(r, newdf,
title=title, boattype=boattype,
workouttype=workouttype,
workoutsource=workoutsource, startdatetime=startdatetime)
workoutsource=workoutsource, startdatetime=startdatetime,
workoutid=workoutid)
try:
checks = row.check_consistency()
allchecks = 1
@@ -1233,26 +1235,59 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
timezone_str = str(workoutstartdatetime.tzinfo)
w = Workout(user=r, name=title, date=workoutdate,
workouttype=workouttype,
boattype=boattype,
dragfactor=dragfactor,
duration=duration, distance=totaldist,
weightcategory=weightcategory,
adaptiveclass=adaptiveclass,
starttime=workoutstarttime,
duplicate=duplicate,
workoutsource=workoutsource,
rankingpiece=rankingpiece,
forceunit=forceunit,
rpe=rpe,
csvfilename=f2, notes=notes, summary=summary,
maxhr=maxhr, averagehr=averagehr,
startdatetime=workoutstartdatetime,
inboard=inboard, oarlength=oarlength,
timezone=timezone_str,
privacy=privacy,
impeller=impeller)
if workoutid:
try:
w = Workout.objects.get(id=workoutid)
w.name = title
w.date = workoutdate
w.workouttype = workouttype
w.boattype = boattype
w.dragfactor = dragfactor
w.duration = duration
w.distance = totaldist
w.weightcategory = weightcategory
w.adaptiveclass = adaptiveclass
w.starttime = workoutstarttime
w.duplicate = duplicate
w.workoutsource = workoutsource
w.rankingpiece = rankingpiece
w.forceunit = forceunit
w.rpe = rpe
w.csvfilename = f2
w.notes = notes
w.summary = summary
w.maxhr = maxhr
w.averagehr = averagehr
w.startdatetime = workoutstartdatetime
w.inboard = inboard
w.oarlength = oarlength
w.timezone = timezone_str
w.privacy = privacy
w.impeller = impeller
except Workout.DoesNotExist:
workoutid = ''
if not workoutid:
w = Workout(user=r, name=title, date=workoutdate,
workouttype=workouttype,
boattype=boattype,
dragfactor=dragfactor,
duration=duration, distance=totaldist,
weightcategory=weightcategory,
adaptiveclass=adaptiveclass,
starttime=workoutstarttime,
duplicate=duplicate,
workoutsource=workoutsource,
rankingpiece=rankingpiece,
forceunit=forceunit,
rpe=rpe,
csvfilename=f2, notes=notes, summary=summary,
maxhr=maxhr, averagehr=averagehr,
startdatetime=workoutstartdatetime,
inboard=inboard, oarlength=oarlength,
timezone=timezone_str,
privacy=privacy,
impeller=impeller)
try:
w.save()
except ValidationError: # pragma: no cover
@@ -1292,6 +1327,7 @@ def new_workout_from_file(r, f2,
makeprivate=False,
startdatetime='',
notes='',
workoutid='',
oarlockfirmware='',
inboard=None,
oarlength=None,
@@ -1463,6 +1499,7 @@ def new_workout_from_file(r, f2,
title=title,
forceunit='N',
impeller=impeller,
workoutid=workoutid,
)
return (id, message, f2)
@@ -1474,6 +1511,7 @@ def new_workout_from_df(r, df,
boattype='1x',
workouttype='rower',
parent=None,
workoutid='',
startdatetime='',
setprivate=False,
forceunit='lbs',
@@ -1541,6 +1579,7 @@ def new_workout_from_df(r, df,
inboard=inboard,
makeprivate=makeprivate,
dosmooth=False,
workoutid=workoutid,
rpe=rpe,
consistencychecks=False)