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 = { record_types_columns = {
'AS': 'ave_speed', # 'Average speed' 'AS': 'ave_speed', # 'Average speed'
'FD': 'distance', # 'Farthest Distance' 'FD': 'distance', # 'Farthest Distance'
'LD': 'duration', # 'Longest Duration' 'LD': 'moving', # 'Longest Duration'
'MS': 'max_speed', # 'Max speed' 'MS': 'max_speed', # 'Max speed'
} }
records = {} records = {}

View File

@ -90,6 +90,7 @@ def activity_cycling_user_1():
) )
activity.max_speed = 10 activity.max_speed = 10
activity.ave_speed = 10 activity.ave_speed = 10
activity.moving = activity.duration
db.session.add(activity) db.session.add(activity)
db.session.commit() db.session.commit()
return activity return activity

View File

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

View File

@ -89,20 +89,22 @@ class ActivityDisplay extends React.Component {
</div> </div>
</div> </div>
</div> </div>
<div className="row"> {activity.with_gpx && (
<div className="col"> <div className="row">
<div className="card"> <div className="col">
<div className="card-body"> <div className="card">
<div className="row"> <div className="card-body">
<div className="col"> <div className="row">
<div className="chart-title">Chart</div> <div className="col">
<ActivityCharts activity={activity} /> <div className="chart-title">Chart</div>
<ActivityCharts activity={activity} />
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> )}
</div> </div>
)} )}
</div> </div>