Private
Public Access
1
0

fixing FITParser

This commit is contained in:
2025-02-18 08:57:45 +01:00
parent 8735a4670f
commit 591bfb0904
2 changed files with 8 additions and 5 deletions

Binary file not shown.

View File

@@ -34,7 +34,7 @@ class FITParser(BaseParser):
return stream.read() return stream.read()
except Exception as e: except Exception as e:
dologging("apilog.log", "FIT Parser") dologging("apilog.log", "FIT Parser")
dolofging("apilog.log", e) dologging("apilog.log", e)
raise ValueError(f"Failed to read FIT file: {str(e)}") raise ValueError(f"Failed to read FIT file: {str(e)}")
return stream.read() return stream.read()
@@ -557,7 +557,8 @@ def strokedata_fit(request):
dologging('apilog.log', request.user.username+" (strokedata_fit POST)") dologging('apilog.log', request.user.username+" (strokedata_fit POST)")
try: try:
fit_data = request.data fit_data = request.data
if not fit_data:
return HttpResponseBadRequest("No FIT data provided.")
# Ensure the media directory exists # Ensure the media directory exists
media_dir = 'media' media_dir = 'media'
os.makedirs(media_dir, exist_ok=True) os.makedirs(media_dir, exist_ok=True)
@@ -621,6 +622,7 @@ def strokedata_fit(request):
'rpe': 0, 'rpe': 0,
'notes': '', 'notes': '',
'id': w.id, 'id': w.id,
'workouttype': 'water',
'offline': False, 'offline': False,
} }
@@ -632,11 +634,12 @@ def strokedata_fit(request):
uploadoptions) uploadoptions)
dologging('apilog.log','FIT file uploaded, returning response') dologging('apilog.log','FIT file uploaded, returning response')
return JsonResponse( returndict = {
{"status": "success", "status": "success",
"workout public id": encoder.encode_hex(w.id), "workout public id": encoder.encode_hex(w.id),
"workout id": w.id, "workout id": w.id,
}) }
return JsonResponse(returndict, status=201)
except Exception as e: except Exception as e:
dologging('apilog.log','FIT API endpoint') dologging('apilog.log','FIT API endpoint')
dologging('apilog.log',e) dologging('apilog.log',e)