Js date is being sent as a string and therefore when attempting to calculate duration an error is thrown
This commit is contained in:
12
app.py
12
app.py
@@ -164,10 +164,10 @@ def workouts(user_id):
|
||||
db.session.add(heart_rate_reading)
|
||||
|
||||
if cadence_readings:
|
||||
start_time = min(
|
||||
c['timestamp'] for c in cadence_readings)
|
||||
end_time = max(
|
||||
c['timestamp'] for c in cadence_readings)
|
||||
timestamps = [datetime_converter(
|
||||
c['timestamp']) for c in cadence_readings]
|
||||
start_time = min(timestamps)
|
||||
end_time = max(timestamps)
|
||||
duration = end_time - start_time
|
||||
duration = duration.total_seconds()
|
||||
average_rpm = sum(
|
||||
@@ -437,6 +437,10 @@ def format_duration(duration):
|
||||
return f"{minutes}m"
|
||||
|
||||
|
||||
def datetime_converter(datetime_str: str) -> datetime:
|
||||
return datetime.strptime(datetime_str, "%Y-%m-%dT%H:%M:%S%z")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Bind to PORT if defined, otherwise default to 5000.
|
||||
port = int(os.environ.get('PORT', 5000))
|
||||
|
||||
Reference in New Issue
Block a user