Private
Public Access
1
0

getting part

This commit is contained in:
2024-04-09 15:50:54 +02:00
parent 016ff6ca6c
commit 6d6acdbd1e
4 changed files with 37 additions and 38 deletions

View File

@@ -2381,14 +2381,16 @@ def history_view_data(request, userid=0):
ids = [w.id for w in g_workouts]
columns = ['hr', 'power', 'time']
df = getsmallrowdata_db(columns, ids=ids)
# columns = ['hr', 'power', 'time']
columns = [name for name, d in metrics.rowingmetrics]+['workoutstate', 'workoutid']
df = getsmallrowdata_pl(columns, ids=ids)
try:
df['deltat'] = df['time'].diff().clip(lower=0)
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(df, workstrokesonly=True,
df = dataprep.clean_df_stats_pl(df, workstrokesonly=True,
ignoreadvanced=True, ignorehr=False)
totalmeters, totalhours, totalminutes, totalseconds = get_totals(
@@ -2418,13 +2420,13 @@ def history_view_data(request, userid=0):
whours=whours,
wminutes=wminutes, wseconds=wseconds,
)
ddf = getsmallrowdata_db(columns, ids=[w.id for w in a_workouts])
ddf = getsmallrowdata_pl(columns, ids=[w.id for w in a_workouts])
try:
ddf['deltat'] = ddf['time'].diff().clip(lower=0)
ddf = ddf.with_columns(pl.col("time").diff().clip(lower_bound=0).alias("deltat"))
except KeyError: # pragma: no cover
pass
ddf = dataprep.clean_df_stats(ddf, workstrokesonly=False,
ddf = dataprep.clean_df_stats_pl(ddf, workstrokesonly=False,
ignoreadvanced=True)
try:
@@ -2432,13 +2434,13 @@ def history_view_data(request, userid=0):
except (KeyError, ValueError, AttributeError): # pragma: no cover
ddict['hrmean'] = 0
try:
ddict['hrmax'] = ddf['hr'].max().astype(int)
ddict['hrmax'] = int(ddf['hr'].max())
except (KeyError, ValueError, AttributeError): # pragma: no cover
ddict['hrmax'] = 0
ddict['powermean'] = int(wavg(ddf, 'power', 'deltat'))
try:
ddict['powermax'] = ddf['power'].max().astype(int)
ddict['powermax'] = int(ddf['power'].max())
except KeyError: # pragma: no cover
ddict['powermax'] = 0
ddict['nrworkouts'] = a_workouts.count()
@@ -2453,13 +2455,13 @@ def history_view_data(request, userid=0):
totalsdict['distance'] = totalmeters
try:
totalsdict['powermean'] = int(wavg(df, 'power', 'deltat'))
totalsdict['powermax'] = df['power'].max().astype(int)
totalsdict['powermax'] = int(df['power'].max())
except KeyError: # pragma: no cover
totalsdict['powermean'] = 0
totalsdict['powermax'] = 0
try:
totalsdict['hrmean'] = int(wavg(df, 'hr', 'deltat'))
totalsdict['hrmax'] = df['hr'].max().astype(int)
totalsdict['hrmax'] = int(df['hr'].max())
except KeyError: # pragma: no cover
totalsdict['hrmean'] = 0
totalsdict['hrmax'] = 0
@@ -2479,14 +2481,14 @@ 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_db(columns, ids=[w.id for w in a_workouts])
ddf = getsmallrowdata_pl(columns, ids=[w.id for w in a_workouts])
try:
ddf['deltat'] = ddf['time'].diff().clip(lower=0)
ddf = ddf.with_columns(pl.col("time").diff().clip(lower_bound=0).alias("deltat"))
except KeyError:
pass
ddf = dataprep.clean_df_stats(ddf, workstrokesonly=True,
ddf = dataprep.clean_df_stats_pl(ddf, workstrokesonly=True,
ignoreadvanced=True)
totalscript, totaldiv = interactive_hr_piechart(