improved workout names
This commit is contained in:
@@ -749,6 +749,19 @@ def clean_df_stats(datadf, workstrokesonly=True, ignorehr=True,
|
||||
|
||||
return datadf
|
||||
|
||||
def getpartofday(dt):
|
||||
h = dt.hour
|
||||
if h < 12:
|
||||
return "Morning"
|
||||
elif h < 18:
|
||||
return "Afternoon"
|
||||
elif h < 22:
|
||||
return "Evening"
|
||||
else:
|
||||
return "Night"
|
||||
|
||||
return None
|
||||
|
||||
def getstatsfields():
|
||||
fielddict = {name:d['verbose_name'] for name,d in rowingmetrics}
|
||||
|
||||
@@ -1140,8 +1153,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
impeller=False):
|
||||
|
||||
message = None
|
||||
if title is None:
|
||||
title = 'Workout'
|
||||
|
||||
|
||||
powerperc = 100 * np.array([r.pw_ut2,
|
||||
r.pw_ut1,
|
||||
@@ -1155,6 +1167,16 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
||||
powerperc=powerperc, powerzones=r.powerzones)
|
||||
row = rdata(f2, rower=rr)
|
||||
|
||||
if title is None or title == '':
|
||||
title = 'Workout'
|
||||
partofday = getpartofday(row.rowdatetime)
|
||||
|
||||
if partofday is not None:
|
||||
title = '{partofday} workout {workouttype}'.format(
|
||||
partofday=partofday,
|
||||
workouttype=workouttype,
|
||||
)
|
||||
|
||||
if row.df.empty:
|
||||
return (0, 'Error: CSV data file was empty')
|
||||
|
||||
@@ -1657,6 +1679,7 @@ def new_workout_from_file(r, f2,
|
||||
r.user.email)
|
||||
|
||||
return (0, message, f2)
|
||||
|
||||
if fileformat == 'att':
|
||||
# email attachment which can safely be ignored
|
||||
return (0, '', f2)
|
||||
|
||||
Reference in New Issue
Block a user