From b66ca710e36247db76a2644ee7194b83ceaa9ac1 Mon Sep 17 00:00:00 2001
From: Sam
Date: Sun, 13 Jan 2019 11:21:14 +0100
Subject: [PATCH] use moving duration in stats - fix #31
---
fittrackee_api/fittrackee_api/activities/stats.py | 4 ++--
fittrackee_api/fittrackee_api/tests/conftest.py | 10 ++++++++++
.../Activity/ActivityDisplay/ActivityDetails.jsx | 15 ++++++---------
.../src/components/Dashboard/ActivityCard.jsx | 2 +-
4 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/fittrackee_api/fittrackee_api/activities/stats.py b/fittrackee_api/fittrackee_api/activities/stats.py
index 4fd493e3..97da785f 100644
--- a/fittrackee_api/fittrackee_api/activities/stats.py
+++ b/fittrackee_api/fittrackee_api/activities/stats.py
@@ -70,7 +70,7 @@ def get_activities(user_id, filter_type):
activities_list[sport_id]['total_distance'] += \
float(activity.distance)
activities_list[sport_id]['total_duration'] += \
- convert_timedelta_to_integer(activity.duration)
+ convert_timedelta_to_integer(activity.moving)
else:
if time == 'week':
@@ -108,7 +108,7 @@ def get_activities(user_id, filter_type):
activities_list[time_period][sport_id]['total_distance'] += \
float(activity.distance)
activities_list[time_period][sport_id]['total_duration'] += \
- convert_timedelta_to_integer(activity.duration)
+ convert_timedelta_to_integer(activity.moving)
response_object = {
'status': 'success',
diff --git a/fittrackee_api/fittrackee_api/tests/conftest.py b/fittrackee_api/fittrackee_api/tests/conftest.py
index 177e2dc1..308c6587 100644
--- a/fittrackee_api/fittrackee_api/tests/conftest.py
+++ b/fittrackee_api/fittrackee_api/tests/conftest.py
@@ -113,6 +113,7 @@ def activity_cycling_user_1_segment():
segment_id=0
)
activity_segment.duration = datetime.timedelta(seconds=6000)
+ activity_segment.moving = activity_segment.duration
activity_segment.distance = 5
db.session.add(activity_segment)
db.session.commit()
@@ -128,6 +129,7 @@ def activity_running_user_1():
distance=12,
duration=datetime.timedelta(seconds=6000)
)
+ activity.moving = activity.duration
db.session.add(activity)
db.session.commit()
return activity
@@ -143,6 +145,7 @@ def seven_activities_user_1():
duration=datetime.timedelta(seconds=1024)
)
activity.ave_speed = float(activity.distance) / (1024 / 3600)
+ activity.moving = activity.duration
db.session.add(activity)
db.session.flush()
activity = Activity(
@@ -153,6 +156,7 @@ def seven_activities_user_1():
duration=datetime.timedelta(seconds=3456)
)
activity.ave_speed = float(activity.distance) / (3456 / 3600)
+ activity.moving = activity.duration
db.session.add(activity)
db.session.flush()
activity = Activity(
@@ -163,6 +167,7 @@ def seven_activities_user_1():
duration=datetime.timedelta(seconds=1024)
)
activity.ave_speed = float(activity.distance) / (1024 / 3600)
+ activity.moving = activity.duration
db.session.add(activity)
db.session.flush()
activity = Activity(
@@ -173,6 +178,7 @@ def seven_activities_user_1():
duration=datetime.timedelta(seconds=600)
)
activity.ave_speed = float(activity.distance) / (600 / 3600)
+ activity.moving = activity.duration
db.session.add(activity)
db.session.flush()
activity = Activity(
@@ -183,6 +189,7 @@ def seven_activities_user_1():
duration=datetime.timedelta(seconds=1000)
)
activity.ave_speed = float(activity.distance) / (1000 / 3600)
+ activity.moving = activity.duration
db.session.add(activity)
db.session.flush()
activity = Activity(
@@ -193,6 +200,7 @@ def seven_activities_user_1():
duration=datetime.timedelta(seconds=6000)
)
activity.ave_speed = float(activity.distance) / (6000 / 3600)
+ activity.moving = activity.duration
db.session.add(activity)
db.session.flush()
activity = Activity(
@@ -203,6 +211,7 @@ def seven_activities_user_1():
duration=datetime.timedelta(seconds=3000)
)
activity.ave_speed = float(activity.distance) / (3000 / 3600)
+ activity.moving = activity.duration
db.session.add(activity)
db.session.commit()
return activity
@@ -217,6 +226,7 @@ def activity_cycling_user_2():
distance=15,
duration=datetime.timedelta(seconds=3600)
)
+ activity.moving = activity.duration
db.session.add(activity)
db.session.commit()
return activity
diff --git a/fittrackee_client/src/components/Activity/ActivityDisplay/ActivityDetails.jsx b/fittrackee_client/src/components/Activity/ActivityDisplay/ActivityDetails.jsx
index cf84fb69..9919ae67 100644
--- a/fittrackee_client/src/components/Activity/ActivityDisplay/ActivityDetails.jsx
+++ b/fittrackee_client/src/components/Activity/ActivityDisplay/ActivityDetails.jsx
@@ -13,15 +13,7 @@ export default function ActivityDetails(props) {
className="fa fa-clock-o custom-fa"
aria-hidden="true"
/>
- Duration: {activity.duration}
- {withPauses && (
-
- {' '}
- (pauses: {activity.pauses})
-
- Moving duration: {activity.moving}
-
- )}
+ Duration: {activity.moving}
{recordLDexists && (
)}
+ {withPauses && (
+
+ (pauses: {activity.pauses}, total duration: {activity.duration})
+
+ )}
{' '}
- Duration: {activity.duration}
+ Duration: {activity.moving}
{activity.map ? (
) : (