Skip to content

Commit

Permalink
Merge pull request yihong0618#399 from stevenash0822/feature_pr
Browse files Browse the repository at this point in the history
[PR] Add: stevenash0822 homepage & Update: calculation of avgPace
  • Loading branch information
yihong0618 authored Apr 18, 2023
2 parents 530d912 + cf4d75c commit 13b9c2d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ R.I.P. 希望大家都能健康顺利的跑过终点,逝者安息。
| [fxbin](https://github.com/fxbin) | <https://fxbin.github.io/sport-records/> | Keep |
| [shensl4499](https://github.com/shensl4499) | <https://waner.run> | codoon |
| [haowei93](https://github.com/haowei93) | <https://haowei93.github.io/ > | gpx |
| [stevenash0822](https://github.com/stevenash0822) | <https://run.imangry.xyz/> | Strava |

</details>

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ English | [简体中文](https://github.com/yihong0618/running_page/blob/master/
| [fxbin](https://github.com/fxbin) | <https://fxbin.github.io/sport-records/> | Keep |
| [shensl4499](https://github.com/shensl4499) | <https://waner.run> | codoon |
| [haowei93](https://github.com/haowei93) | <https://haowei93.github.io/ > | gpx |
| [stevenash0822](https://github.com/stevenash0822) | <https://run.imangry.xyz/> | Strava |


</details>
Expand Down
6 changes: 5 additions & 1 deletion src/components/YearStat/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand All @@ -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
Expand Down

0 comments on commit 13b9c2d

Please sign in to comment.