Private
Public Access
1
0
This commit is contained in:
2024-04-20 17:14:22 +02:00
parent ffe295d8fc
commit 30bf61cbe1
10 changed files with 76 additions and 157 deletions

View File

@@ -571,7 +571,7 @@ def flexalldata(workouts, options):
workstrokesonly = not includereststrokes
columns = [xparam, yparam1, yparam2, 'spm', 'driveenergy', 'distance']
ids = [int(w.id) for w in workouts]
df = dataprep.getsmallrowdata_pl(columns, ids=ids,
df = dataprep.read_data(columns, ids=ids,
workstrokesonly=workstrokesonly,
doclean=True,
)
@@ -928,9 +928,9 @@ def boxplotdata(workouts, options):
ids = [w.id for w in workouts]
# prepare data frame
datadf = getsmallrowdata_pl(fieldlist, ids)
datadf = dataprep.read_data(fieldlist, ids)
datadf = dataprep.clean_df_stats_pl(datadf, workstrokesonly=workstrokesonly)
datadf = dataprep.remove_nulls_pl(datadf)
try:
datadf = datadf.filter(
@@ -2361,17 +2361,16 @@ def history_view_data(request, userid=0):
ids = [w.id for w in g_workouts]
# columns = ['hr', 'power', 'time']
columns = [name for name, d in metrics.rowingmetrics]+['workoutstate', 'workoutid']
columns = ['hr', 'power', 'time', 'workoutstate', 'workoutid']
df = dataprep.read_data(columns, ids=ids)
df = dataprep.remove_nulls_pl(df)
df = getsmallrowdata_pl(columns, ids=ids)
try:
df = df.with_columns(pl.col('time').diff().clip(lower_bound=0).alias("deltat"))
except KeyError: # pragma: no cover
pass
df = dataprep.clean_df_stats_pl(df, workstrokesonly=True,
ignoreadvanced=True, ignorehr=False)
totalmeters, totalhours, totalminutes, totalseconds = get_totals(
g_workouts)
@@ -2400,7 +2399,8 @@ def history_view_data(request, userid=0):
whours=whours,
wminutes=wminutes, wseconds=wseconds,
)
ddf = getsmallrowdata_pl(columns, ids=[w.id for w in a_workouts])
ddf = dataprep.read_data(columns, ids=[w.id for w in a_workouts])
ddf = dataprep.remove_nulls_pl(ddf)
try:
ddf = ddf.with_columns(pl.col("time").diff().clip(lower_bound=0).alias("deltat"))
except KeyError: # pragma: no cover
@@ -2421,7 +2421,7 @@ def history_view_data(request, userid=0):
ddict['powermean'] = int(wavg(ddf, 'power', 'deltat'))
try:
ddict['powermax'] = int(ddf['power'].max())
except KeyError: # pragma: no cover
except (KeyError, ColumnNotFoundError): # pragma: no cover
ddict['powermax'] = 0
ddict['nrworkouts'] = a_workouts.count()
listofdicts.append(ddict)
@@ -2436,13 +2436,13 @@ def history_view_data(request, userid=0):
try:
totalsdict['powermean'] = int(wavg(df, 'power', 'deltat'))
totalsdict['powermax'] = int(df['power'].max())
except KeyError: # pragma: no cover
except (KeyError, ColumnNotFoundError): # pragma: no cover
totalsdict['powermean'] = 0
totalsdict['powermax'] = 0
try:
totalsdict['hrmean'] = int(wavg(df, 'hr', 'deltat'))
totalsdict['hrmax'] = int(df['hr'].max())
except KeyError: # pragma: no cover
except (KeyError, ColumnNotFoundError): # pragma: no cover
totalsdict['hrmean'] = 0
totalsdict['hrmax'] = 0
@@ -2461,7 +2461,8 @@ def history_view_data(request, userid=0):
a_workouts = g_workouts.filter(workouttype=typeselect)
meters, hours, minutes, seconds = get_totals(a_workouts)
totalseconds = 3600 * hours + 60 * minutes + seconds
ddf = getsmallrowdata_pl(columns, ids=[w.id for w in a_workouts])
ddf = dataprep.read_data(columns, ids=[w.id for w in a_workouts])
ddf = dataprep.remove_nulls_pl(ddf)
if ddf.is_empty():
totalscript = ""
totaldiv = "No data"