diff --git a/rowers/dataprep.py b/rowers/dataprep.py index 582815e0..4100b8d5 100644 --- a/rowers/dataprep.py +++ b/rowers/dataprep.py @@ -126,8 +126,7 @@ def rscore_approx(row): else: dd = 3600*row['duration'].hour+60*row['duration'].minute+row['duration'].second dd = dd/3600 - print(row['rpe'],dd,rpetotss[row['rpe']]) - return rpetotss[row['rpe']]*dd + return int(rpetotss[row['rpe']]*dd) if row['rscore'] < 0: w = Workout.objects.get(id=row['id']) trimp, hrtss = workout_trimp(w) @@ -135,12 +134,11 @@ def rscore_approx(row): if row['rpe'] and row['rpe'] > 0: dd = 3600*row['duration'].hour+60*row['duration'].minute+row['duration'].second dd = dd/3600 - return rpetotss[row['rpe']]*dd + return int(rpetotss[row['rpe']]*dd) else: # pragma: no cover minutes = row['duration'].hour*60+row['duration'].minute return minutes - print('boer') return 0 diff --git a/rowers/nkimportutils.py b/rowers/nkimportutils.py index e8394bec..b2d495f4 100644 --- a/rowers/nkimportutils.py +++ b/rowers/nkimportutils.py @@ -110,7 +110,7 @@ def add_workout_from_data(userid, nkid, data, strokedata, source='nk', splitdata 'seatNumber': seatNumber, } - # dologging('nklog.log',json.dumps(uploadoptions)) + dologging('nklog.log',json.dumps(uploadoptions)) session = requests.session() newHeaders = {'Content-type': 'application/json', 'Accept': 'text/plain'} diff --git a/rowers/tasks.py b/rowers/tasks.py index 41e28396..a037a37d 100644 --- a/rowers/tasks.py +++ b/rowers/tasks.py @@ -359,7 +359,7 @@ def uploadactivity(access_token, filename, description='', with gzip.GzipFile(fileobj=data_gz, mode="w") as gzf: gzf.write(s) except FileNotFoundError: - return 0 + return 0, 0, 0, 0 headers = { 'Content-Type': 'application/json', @@ -2644,8 +2644,12 @@ def handle_makeplot(f1, f2, t, hrdata, plotnr, imagename, nr_rows = len(row.df) if (plotnr in [1, 2, 4, 5, 8, 11, 9, 12]) and (nr_rows > 1200): # pragma: no cover bin = int(nr_rows / 1200.) - df = row.df.groupby(lambda x: x / bin).mean() - row.df = df + try: + df = df.select_types(['number']) + df = row.df.groupby(lambda x: x / bin).mean() + row.df = df + except TypeError: + pass nr_rows = len(row.df) if (plotnr == 1): fig1 = row.get_timeplot_erg(t, pacerange=oterange, **kwargs) diff --git a/rowers/tests/testdata/testdata.tcx.gz b/rowers/tests/testdata/testdata.tcx.gz index 36a4f214..a6ad89e0 100644 Binary files a/rowers/tests/testdata/testdata.tcx.gz and b/rowers/tests/testdata/testdata.tcx.gz differ diff --git a/rowers/views/planviews.py b/rowers/views/planviews.py index 3d5df328..a3a424ad 100644 --- a/rowers/views/planviews.py +++ b/rowers/views/planviews.py @@ -1518,12 +1518,15 @@ def plannedsessions_view(request, for w in ws: thetrimp, hrtss = dataprep.workout_trimp(w) totals['trimp'] += thetrimp - tss = dataprep.workout_rscore(w)[0] - if not np.isnan(tss) and tss != 0: - totals['rscore'] += tss - elif tss == 0: - totals['rscore'] += hrtss - tss = hrtss + row = { + 'rscore': w.rscore, + 'hrtss': w.hrtss, + 'rpe': w.rpe, + 'duration': w.duration, + 'id': w.id + } + tss = dataprep.rscore_approx(row) + totals['rscore'] += tss totals['distance'] += w.distance totals['time'] += timefield_to_seconds_duration(w.duration) if w.plannedsession: # pragma: no cover