use moving duration in stats - fix #31

This commit is contained in:
Sam 2019-01-13 11:21:14 +01:00
parent ab8d640956
commit b66ca710e3
4 changed files with 19 additions and 12 deletions

View File

@ -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',

View File

@ -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

View File

@ -13,15 +13,7 @@ export default function ActivityDetails(props) {
className="fa fa-clock-o custom-fa"
aria-hidden="true"
/>
Duration: {activity.duration}
{withPauses && (
<span>
{' '}
(pauses: {activity.pauses})
<br />
Moving duration: {activity.moving}
</span>
)}
Duration: {activity.moving}
{recordLDexists && (
<sup>
<i
@ -30,6 +22,11 @@ export default function ActivityDetails(props) {
/>
</sup>
)}
{withPauses && (
<p>
(pauses: {activity.pauses}, total duration: {activity.duration})
</p>
)}
</p>
<p>
<i

View File

@ -49,7 +49,7 @@ export default function ActivityCard (props) {
<div className="col">
<p>
<i className="fa fa-clock-o" aria-hidden="true" />{' '}
Duration: {activity.duration}
Duration: {activity.moving}
{activity.map ? (
<span><br /><br /></span>
) : (