Skip to content

Commit 1cb5311

Browse files
authored
Merge branch 'yihong0618:master' into master
2 parents 804c7c9 + 65a9997 commit 1cb5311

6 files changed

Lines changed: 39 additions & 13 deletions

File tree

README-CN.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,6 @@ python3 run_page/auto_share_sync.py --api_key xxxxxxxxx --base_url xxxxxxxx --da
12341234
4. 为 GitHub Actions 添加代码提交权限,访问仓库的 `Settings > Actions > General`页面,找到 `Workflow permissions` 的设置项,将选项配置为 `Read and write permissions`,支持 CI 将运动数据更新后提交到仓库中。
12351235

12361236
5. 如果想把你的 running_page 部署在 xxx.github.io 而不是 xxx.github.io/run_page 亦或是想要添加自定义域名于 GitHub Pages,需要做三点
1237-
12381237
- 修改你的 fork 的 running_page 仓库改名为 xxx.github.io, xxx 是你 github 的 username
12391238
- 修改 gh-pages.yml 中的 Build 模块,删除 `${{ github.event.repository.name }}` 改为`run: PATH_PREFIX=/ pnpm build` 即可
12401239
- 修改 src/static/site-metadata.ts 中 `siteUrl: ''` 或是添加你的自定义域名,`siteUrl: '[your_own_domain]'`,即可

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,6 @@ For more display effects, see:
10071007
4. make sure you have write permissions in Workflow permissions settings.
10081008
10091009
5. If you want to deploy your running_page to xxx.github.io instead of xxx.github.io/running_page or redirect your GitHub Pages to a custom domain, you need to do three things:
1010-
10111010
- Rename your forked running_page repository to `xxx.github.io`, where xxx is your GitHub username
10121011
- Modify the Build module in gh-pages.yml, remove `${{ github.event.repository.name }}` and change to `run: PATH_PREFIX=/ pnpm build`
10131012
- In `src/static/site-metadata.ts`, set siteUrl: '' or your custom domain URL

run_page/gpxtrackposter/track.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,16 @@ def _load_gpx_data(self, gpx):
216216
self.start_time, self.end_time = gpx.get_time_bounds()
217217
if self.start_time is None or self.end_time is None:
218218
# may be it's treadmill run, so we just use the start and end time of the extensions
219-
self.start_time = datetime.datetime.fromisoformat(
220-
self._load_gpx_extensions_item(gpx, "start_time")
221-
)
222-
self.end_time = datetime.datetime.fromisoformat(
223-
self._load_gpx_extensions_item(gpx, "end_time")
224-
)
225-
self.start_time_local, self.end_time_local = parse_datetime_to_local(
226-
self.start_time, self.end_time, None
227-
)
219+
start_time_str = self._load_gpx_extensions_item(gpx, "start_time")
220+
end_time_str = self._load_gpx_extensions_item(gpx, "end_time")
221+
if start_time_str:
222+
self.start_time = datetime.datetime.fromisoformat(start_time_str)
223+
if end_time_str:
224+
self.end_time = datetime.datetime.fromisoformat(end_time_str)
225+
if self.start_time and self.end_time:
226+
self.start_time_local, self.end_time_local = parse_datetime_to_local(
227+
self.start_time, self.end_time, None
228+
)
228229
# use timestamp as id
229230
self.run_id = self.__make_run_id(self.start_time)
230231
if self.start_time is None:

run_page/keep_sync.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def get_all_keep_tracks(
213213
)
214214
tracks.append(track)
215215
except Exception as e:
216-
print(f"Something wrong paring keep id {run}" + str(e))
216+
print(f"Something wrong paring keep id {run}: " + str(e))
217217
return tracks
218218

219219

@@ -232,7 +232,10 @@ def parse_points_to_gpx(run_points_data, start_time, sport_type):
232232
points_dict_list = []
233233
# early timestamp fields in keep's data stands for delta time, but in newly data timestamp field stands for exactly time,
234234
# so it doesn't need to plus extra start_time
235-
if run_points_data[0]["timestamp"] > TIMESTAMP_THRESHOLD_IN_DECISECOND:
235+
if (
236+
run_points_data
237+
and run_points_data[0]["timestamp"] > TIMESTAMP_THRESHOLD_IN_DECISECOND
238+
):
236239
start_time = 0
237240

238241
for point in run_points_data:

src/components/ActivityList/index.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface Activity {
2626
type: string;
2727
location_country?: string;
2828
elevation_gain?: number; // Optional if elevation gain is not used
29+
average_heartrate?: number; // Add heart rate support
2930
}
3031

3132
interface ActivitySummary {
@@ -37,6 +38,8 @@ interface ActivitySummary {
3738
maxDistance: number;
3839
maxSpeed: number;
3940
location: string;
41+
totalHeartRate: number; // Add heart rate statistics
42+
heartRateCount: number;
4043
}
4144

4245
interface DisplaySummary {
@@ -48,6 +51,7 @@ interface DisplaySummary {
4851
maxSpeed: number;
4952
location: string;
5053
totalElevationGain?: number;
54+
averageHeartRate?: number; // Add heart rate display
5155
}
5256

5357
interface ChartData {
@@ -139,6 +143,12 @@ const ActivityCard: React.FC<ActivityCardProps> = ({
139143
<strong>{ACTIVITY_TOTAL.TOTAL_TIME_TITLE}:</strong>{' '}
140144
{formatTime(summary.totalTime)}
141145
</p>
146+
{summary.averageHeartRate !== undefined && (
147+
<p>
148+
<strong>{ACTIVITY_TOTAL.AVERAGE_HEART_RATE_TITLE}:</strong>{' '}
149+
{summary.averageHeartRate.toFixed(0)} bpm
150+
</p>
151+
)}
142152
{interval !== 'day' && (
143153
<>
144154
<p>
@@ -257,6 +267,8 @@ const ActivityList: React.FC = () => {
257267
maxDistance: 0,
258268
maxSpeed: 0,
259269
location: '',
270+
totalHeartRate: 0,
271+
heartRateCount: 0,
260272
};
261273

262274
const distanceKm = activity.distance / 1000; // Convert to kilometers
@@ -271,6 +283,12 @@ const ActivityList: React.FC = () => {
271283
acc[key].totalElevationGain += activity.elevation_gain;
272284
}
273285

286+
// Heart rate statistics
287+
if (activity.average_heartrate) {
288+
acc[key].totalHeartRate += activity.average_heartrate;
289+
acc[key].heartRateCount += 1;
290+
}
291+
274292
acc[key].count += 1;
275293

276294
// Accumulate daily distances
@@ -354,6 +372,10 @@ const ActivityList: React.FC = () => {
354372
totalElevationGain: SHOW_ELEVATION_GAIN
355373
? summary.totalElevationGain
356374
: undefined,
375+
averageHeartRate:
376+
summary.heartRateCount > 0
377+
? summary.totalHeartRate / summary.heartRateCount
378+
: undefined,
357379
}}
358380
dailyDistances={summary.dailyDistances}
359381
interval={interval}

src/utils/const.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ const TOTAL_DISTANCE_TITLE = IS_CHINESE ? '总距离' : 'Total Distance';
8888
const TOTAL_ELEVATION_GAIN_TITLE = IS_CHINESE
8989
? '总海拔爬升'
9090
: 'Total Elevation Gain';
91+
const AVERAGE_HEART_RATE_TITLE = IS_CHINESE ? '平均心率' : 'Average Heart Rate';
9192
const YEARLY_TITLE = IS_CHINESE ? 'Year' : 'Yearly';
9293
const MONTHLY_TITLE = IS_CHINESE ? 'Month' : 'Monthly';
9394
const WEEKLY_TITLE = IS_CHINESE ? 'Week' : 'Weekly';
@@ -121,6 +122,7 @@ const ACTIVITY_TOTAL = {
121122
AVERAGE_SPEED_TITLE,
122123
TOTAL_DISTANCE_TITLE,
123124
TOTAL_ELEVATION_GAIN_TITLE,
125+
AVERAGE_HEART_RATE_TITLE,
124126
YEARLY_TITLE,
125127
MONTHLY_TITLE,
126128
WEEKLY_TITLE,

0 commit comments

Comments
 (0)