APi & Client: 'moving duration' instead of 'total duration' for record

This commit is contained in:
Sam 2018-05-29 20:43:44 +02:00
parent bddb86d765
commit 0c6c588e74
4 changed files with 24 additions and 16 deletions

View File

@ -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 = {}

View File

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

View File

@ -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 (
<div>
<p>
@ -10,18 +12,21 @@ export default function ActivityDetails(props) {
aria-hidden="true"
/>
Duration: {activity.duration}
{activity.records.find(r => r.record_type === 'LD'
) && (
{withPauses && (
<span>
{' '}
(pauses: {activity.pauses})
<br />
Moving duration: {activity.moving}
</span>
)}
{recordLDexists && (
<sup>
<i
className="fa fa-trophy custom-fa"
aria-hidden="true"
/>
</sup>
)} {' '}
{activity.pauses !== '0:00:00' &&
activity.pauses !== null && (
`(pauses: ${activity.pauses})`
)}
</p>
<p>

View File

@ -89,6 +89,7 @@ class ActivityDisplay extends React.Component {
</div>
</div>
</div>
{activity.with_gpx && (
<div className="row">
<div className="col">
<div className="card">
@ -103,6 +104,7 @@ class ActivityDisplay extends React.Component {
</div>
</div>
</div>
)}
</div>
)}
</div>