diff --git a/README-CN.md b/README-CN.md index c188fb01603..8fd77adee2d 100644 --- a/README-CN.md +++ b/README-CN.md @@ -66,6 +66,7 @@ R.I.P. 希望大家都能健康顺利的跑过终点,逝者安息。 | [fxbin](https://github.com/fxbin) | | Keep | | [shensl4499](https://github.com/shensl4499) | | codoon | | [haowei93](https://github.com/haowei93) | | gpx | +| [stevenash0822](https://github.com/stevenash0822) | | Strava | diff --git a/README.md b/README.md index 916cac52cad..0e58d7a02d7 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ English | [简体中文](https://github.com/yihong0618/running_page/blob/master/ | [fxbin](https://github.com/fxbin) | | Keep | | [shensl4499](https://github.com/shensl4499) | | codoon | | [haowei93](https://github.com/haowei93) | | gpx | +| [stevenash0822](https://github.com/stevenash0822) | | Strava | diff --git a/src/components/YearStat/index.jsx b/src/components/YearStat/index.jsx index 5484d41fa42..0f6aecc157b 100644 --- a/src/components/YearStat/index.jsx +++ b/src/components/YearStat/index.jsx @@ -25,10 +25,14 @@ const YearStat = ({ year, onClick }) => { let paceNullCount = 0; let heartRate = 0; let heartRateNullCount = 0; + let totalMetersAvail = 0; + let totalSecondsAvail = 0; runs.forEach((run) => { sumDistance += run.distance || 0; if (run.average_speed) { pace += run.average_speed; + totalMetersAvail += run.distance || 0; + totalSecondsAvail += (run.distance || 0) / run.average_speed; } else { paceNullCount++; } @@ -42,7 +46,7 @@ const YearStat = ({ year, onClick }) => { } }); sumDistance = (sumDistance / 1000.0).toFixed(1); - const avgPace = formatPace(pace / (runs.length - paceNullCount)); + const avgPace = formatPace(totalMetersAvail / totalSecondsAvail); const hasHeartRate = !(heartRate === 0); const avgHeartRate = (heartRate / (runs.length - heartRateNullCount)).toFixed( 0