Private
Public Access
1
0

ignore duplicates for rolling wps

This commit is contained in:
2025-01-09 15:30:47 +01:00
parent e191ab4fc3
commit 26a5f7acfc
6 changed files with 39 additions and 14 deletions

View File

@@ -1453,9 +1453,10 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
_ = update_wps(r, mytypes.otetypes)
# set user running wps
if workouttype in otetypes:
if not duplicate and workouttype in otetypes:
cntr = Workout.objects.filter(user=r, workouttype__in=otetypes,
startdatetime__gt=tz.now()-tz.timedelta(days=42)).count()
startdatetime__gt=tz.now()-tz.timedelta(days=42),
duplicate=False).count()
new_value = (cntr*r.running_wps_erg + row.df['driveenergy'].mean())/(cntr+1.0)
# if new_value is not zero or infinite or -inf, r.running_wps can be set to value
if not (math.isnan(new_value) or math.isinf(new_value) or new_value == 0):
@@ -1466,9 +1467,10 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
r.running_wps_erg = 600.
r.save()
if workouttype in otwtypes:
if not duplicate and workouttype in otwtypes:
cntr = Workout.objects.filter(user=r, workouttype__in=otwtypes,
startdatetime__gt=tz.now()-tz.timedelta(days=42)).count()
startdatetime__gt=tz.now()-tz.timedelta(days=42),
duplicate=False).count()
new_value = (cntr*r.running_wps_erg + row.df['driveenergy'].mean())/(cntr+1.0)
if not (math.isnan(new_value) or math.isinf(new_value) or new_value == 0):
r.running_wps = new_value