bulk export through fit files
This commit is contained in:
@@ -386,18 +386,13 @@ def email_all_user_workouts_zip(rower, start_date=None, end_date=None, debug=Fal
|
|||||||
for workout in workouts:
|
for workout in workouts:
|
||||||
try:
|
try:
|
||||||
rowdata = rdata(csvfile=workout.csvfilename)
|
rowdata = rdata(csvfile=workout.csvfilename)
|
||||||
rowdate = rowdata.rowdatetime
|
workouttype = mytypes.fitmapping.get(workout.workouttype, 'generic')
|
||||||
starttimeunix = arrow.get(rowdate).timestamp()
|
|
||||||
df = rowdata.df
|
|
||||||
|
|
||||||
try:
|
fit_filename = f"workout_{workout.id}_{workout.date.strftime('%Y%m%d')}.fit"
|
||||||
df[' ElapsedTime (sec)'] = df['TimeStamp (sec)']
|
# exporttofit creates a file, we need to add it to the zip_file
|
||||||
df['TimeStamp (sec)'] = df['TimeStamp (sec)'] + starttimeunix
|
rowdata.exporttofit(fit_filename, sport=workouttype, notes=workout.name)
|
||||||
except KeyError:
|
zip_file.write(fit_filename, arcname=fit_filename)
|
||||||
pass
|
os.remove(fit_filename)
|
||||||
|
|
||||||
csv_filename = f"workout_{workout.id}_{workout.date.strftime('%Y%m%d')}.csv"
|
|
||||||
zip_file.writestr(csv_filename, df.to_csv(index=False))
|
|
||||||
except Exception as e: # pragma: no cover
|
except Exception as e: # pragma: no cover
|
||||||
dologging('export_all_workouts.log', f"Error exporting workout {workout.id}: {str(e)}")
|
dologging('export_all_workouts.log', f"Error exporting workout {workout.id}: {str(e)}")
|
||||||
continue
|
continue
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
Reference in New Issue
Block a user