From 0c6c588e74b190fe0eb08e2272d88577502e1a15 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 29 May 2018 20:43:44 +0200 Subject: [PATCH] APi & Client: 'moving duration' instead of 'total duration' for record --- mpwo_api/mpwo_api/activities/models.py | 2 +- mpwo_api/mpwo_api/tests/conftest.py | 1 + .../ActivityDisplay/ActivityDetails.jsx | 17 ++++++++++------ .../Activities/ActivityDisplay/index.jsx | 20 ++++++++++--------- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/mpwo_api/mpwo_api/activities/models.py b/mpwo_api/mpwo_api/activities/models.py index 951c2b07..ec0e7a90 100644 --- a/mpwo_api/mpwo_api/activities/models.py +++ b/mpwo_api/mpwo_api/activities/models.py @@ -204,7 +204,7 @@ class Activity(db.Model): record_types_columns = { 'AS': 'ave_speed', # 'Average speed' 'FD': 'distance', # 'Farthest Distance' - 'LD': 'duration', # 'Longest Duration' + 'LD': 'moving', # 'Longest Duration' 'MS': 'max_speed', # 'Max speed' } records = {} diff --git a/mpwo_api/mpwo_api/tests/conftest.py b/mpwo_api/mpwo_api/tests/conftest.py index 3e2503ac..c3a6516e 100644 --- a/mpwo_api/mpwo_api/tests/conftest.py +++ b/mpwo_api/mpwo_api/tests/conftest.py @@ -90,6 +90,7 @@ def activity_cycling_user_1(): ) activity.max_speed = 10 activity.ave_speed = 10 + activity.moving = activity.duration db.session.add(activity) db.session.commit() return activity diff --git a/mpwo_client/src/components/Activities/ActivityDisplay/ActivityDetails.jsx b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityDetails.jsx index 91984efd..f3d19f85 100644 --- a/mpwo_client/src/components/Activities/ActivityDisplay/ActivityDetails.jsx +++ b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityDetails.jsx @@ -2,6 +2,8 @@ import React from 'react' export default function ActivityDetails(props) { const { activity } = props + const withPauses = activity.pauses !== '0:00:00' && activity.pauses !== null + const recordLDexists = activity.records.find(r => r.record_type === 'LD') return (

@@ -10,18 +12,21 @@ export default function ActivityDetails(props) { aria-hidden="true" /> Duration: {activity.duration} - {activity.records.find(r => r.record_type === 'LD' - ) && ( + {withPauses && ( + + {' '} + (pauses: {activity.pauses}) +
+ Moving duration: {activity.moving} +
+ )} + {recordLDexists && (