Skip to content

Commit 962bcbd

Browse files
committed
update summary effort
1 parent f01e948 commit 962bcbd

File tree

3 files changed

+70
-24
lines changed

3 files changed

+70
-24
lines changed

data/events.json

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"name": "EDP Lisbon Marathon",
88
"distance": "42.2",
99
"time": "05:37",
10+
"time_limit": "06:00",
1011
"link": "https://www.running-portugal.com/lisbon/marathon/en/home.html",
1112
"tags": {
1213
"date": ["2024", "Q4"],
@@ -889,6 +890,7 @@
889890
"name": "Split Marathon",
890891
"distance": "42.2",
891892
"time": "04:31",
893+
"time_limit": "06:00",
892894
"link": "https://splitmarathon.com/marathon/?lang=en",
893895
"tags": {
894896
"date": ["2025", "Q1"],
@@ -1383,6 +1385,7 @@
13831385
"name": "OPAP Limassol Marathon",
13841386
"distance": "42.2",
13851387
"time": "04:24",
1388+
"time_limit": "06:00",
13861389
"link": "https://www.limassolmarathon.com/index.php",
13871390
"tags": {
13881391
"date": ["2025", "Q1"],
@@ -1762,6 +1765,7 @@
17621765
"name": "Wizz Air Milano Marathon",
17631766
"distance": "42.2",
17641767
"time": "04:52",
1768+
"time_limit": "06:30",
17651769
"link": "https://www.milanomarathon.it/en/marathon/",
17661770
"tags": {
17671771
"date": ["2025", "Q2"],
@@ -2165,6 +2169,9 @@
21652169
"distance": "42.2",
21662170
"ascent": "578",
21672171
"time": "04:43",
2172+
"time_limit": "06:00",
2173+
"average_hr": "160",
2174+
"max_hr": "178",
21682175
"link": "https://www.maratonadellisoladelba.it/",
21692176
"tags": {
21702177
"date": ["2025", "Q2"],
@@ -8861,6 +8868,9 @@
88618868
"distance": "42.2",
88628869
"ascent": "223",
88638870
"time": "04:09",
8871+
"time_limit": "06:30",
8872+
"average_hr": "168",
8873+
"max_hr": "182",
88648874
"link": "https://www.stockholmmarathon.se/eng/",
88658875
"tags": {
88668876
"date": ["2025", "Q2"],
@@ -12605,6 +12615,9 @@
1260512615
"distance": "45.3",
1260612616
"ascent": "2447",
1260712617
"time": "06:54",
12618+
"time_limit": "07:50",
12619+
"average_hr": "158",
12620+
"max_hr": "175",
1260812621
"link": "https://www.zermattmarathon.ch/en/index.html",
1260912622
"tags": {
1261012623
"date": ["2025", "Q3"],
@@ -18778,6 +18791,9 @@
1877818791
"distance": "42.2",
1877918792
"ascent": "251",
1878018793
"time": "03:44",
18794+
"time_limit": "06:30",
18795+
"average_hr": "162",
18796+
"max_hr": "178",
1878118797
"link": "https://www.rmi.is/en",
1878218798
"tags": {
1878318799
"date": ["2025", "Q3"],
@@ -18826,6 +18842,9 @@
1882618842
"distance": "42.2",
1882718843
"ascent": "1993",
1882818844
"time": "05:56",
18845+
"time_limit": "07:30",
18846+
"average_hr": "160",
18847+
"max_hr": "187",
1882918848
"link": "https://www.jungfrau-marathon.ch/en/marathon.html",
1883018849
"tags": {
1883118850
"date": ["2025", "Q3"],
@@ -18869,6 +18888,9 @@
1886918888
"distance": "12",
1887018889
"ascent": "620",
1887118890
"time": "02:00",
18891+
"time_limit": "17:00",
18892+
"average_hr": "155",
18893+
"max_hr": "171",
1887218894
"link": "https://utlm.it/en/",
1887318895
"status": "cancelled",
1887418896
"tags": {
@@ -18902,6 +18924,9 @@
1890218924
"distance": "42.2",
1890318925
"ascent": "66",
1890418926
"time": "03:35",
18927+
"time_limit": "06:00",
18928+
"average_hr": "165",
18929+
"max_hr": "180",
1890518930
"link": "https://www.venicemarathon.it/en",
1890618931
"tags": {
1890718932
"date": ["2025", "Q4"],
@@ -18931,9 +18956,7 @@
1893118956
"Stations used water bottles which is great because you can take it and fill up your bottles with electrolytes as you run.",
1893218957
"Start zones were weird, slower pacers started way to far into the middle creating walls and somehow my zone was behind them when I was much faster."
1893318958
],
18934-
"takeaways": [
18935-
"Running more helped but needed more time/gadgets to recover."
18936-
]
18959+
"takeaways": ["Running more helped but needed more time/gadgets to recover."]
1893718960
},
1893818961
"route": []
1893918962
},
@@ -18946,6 +18969,9 @@
1894618969
"distance": "42.2",
1894718970
"ascent": "116",
1894818971
"time": "04:27",
18972+
"time_limit": "06:00",
18973+
"average_hr": "160",
18974+
"max_hr": "180",
1894918975
"link": "https://www.marathon06.com/2025/AN/",
1895018976
"tags": {
1895118977
"date": ["2025", "Q4"],
@@ -18982,6 +19008,9 @@
1898219008
"distance": "42.2",
1898319009
"ascent": "93",
1898419010
"time": "03:52",
19011+
"time_limit": "06:00",
19012+
"average_hr": "167",
19013+
"max_hr": "184",
1898519014
"link": "https://www.firenzemarathon.it/en/marathon/",
1898619015
"tags": {
1898719016
"date": ["2025", "Q4"],
@@ -19015,6 +19044,9 @@
1901519044
"distance": "42.2",
1901619045
"ascent": "137",
1901719046
"time": "04:17",
19047+
"time_limit": "05:30",
19048+
"average_hr": "161",
19049+
"max_hr": "178",
1901819050
"link": "https://www.generalimaratonmalaga.com/marathon-malaga-en/",
1901919051
"tags": {
1902019052
"date": ["2025", "Q4"],
@@ -19046,6 +19078,9 @@
1904619078
"distance": "62",
1904719079
"ascent": "2015",
1904819080
"time": "13:09",
19081+
"time_limit": "15:00",
19082+
"average_hr": "139",
19083+
"max_hr": "177",
1904919084
"link": "https://www.s1trail.com/en/s1-trail/",
1905019085
"tags": {
1905119086
"date": ["2026", "Q1"],
@@ -19084,6 +19119,9 @@
1908419119
"distance": "27",
1908519120
"ascent": "1555",
1908619121
"time": "04:30",
19122+
"time_limit": "12:50",
19123+
"average_hr": "153",
19124+
"max_hr": "184",
1908719125
"link": "https://ultramediterrania.com/",
1908819126
"status": "cancelled",
1908919127
"tags": {

src/components/left-sidebar/Summary.tsx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -124,29 +124,29 @@ const EventTableHead = ({
124124
</TableHead>
125125
);
126126

127-
const calculateEffort = (event: Event): number => {
127+
const parseTimeToHours = (timeStr: string): number => {
128+
if (!timeStr) return 0;
129+
const parts = timeStr.trim().split(":").map((p) => p.trim());
130+
if (parts.length === 2) {
131+
const [hours, minutes] = parts.map(Number);
132+
return hours + minutes / 60;
133+
} else if (parts.length === 3) {
134+
const [hours, minutes, seconds] = parts.map(Number);
135+
return hours + minutes / 60 + seconds / 3600;
136+
}
137+
return 0;
138+
};
139+
140+
const calculateEffort = (event: Event): number | null => {
128141
const distance = parseFloat(event.distance) || 0;
129142
const ascent = event.ascent ? parseFloat(event.ascent) : 0;
130-
131-
const parseTimeToHours = (timeStr: string): number => {
132-
const parts = timeStr
133-
.trim()
134-
.split(":")
135-
.map((p) => p.trim());
136-
if (parts.length === 2) {
137-
const [hours, minutes] = parts.map(Number);
138-
return hours + minutes / 60;
139-
} else if (parts.length === 3) {
140-
const [hours, minutes, seconds] = parts.map(Number);
141-
return hours + minutes / 60 + seconds / 3600;
142-
}
143-
return 0;
144-
};
145-
146143
const timeHours = parseTimeToHours(event.time);
147-
if (timeHours === 0) return 0;
148-
149-
const effort = (distance + ascent / 100) / timeHours;
144+
if (timeHours === 0) return null;
145+
const baseEffort = (distance + ascent / 100) / timeHours;
146+
const avgHr = event.average_hr ? parseFloat(event.average_hr) : null;
147+
const maxHr = event.max_hr ? parseFloat(event.max_hr) : null;
148+
if (avgHr === null || maxHr === null || maxHr === 0) return null;
149+
const effort = baseEffort * (avgHr / maxHr);
150150
return Math.round(effort * 100) / 100;
151151
};
152152

@@ -175,7 +175,9 @@ const EventTableRow = ({ event }: { event: Event }) => {
175175
<TableCell sx={{ fontSize: "0.9rem" }}>
176176
{event.ascent ? `${event.ascent}m` : ""}
177177
</TableCell>
178-
<TableCell sx={{ fontSize: "0.9rem" }}>{effort.toFixed(2)}</TableCell>
178+
<TableCell sx={{ fontSize: "0.9rem" }}>
179+
{effort !== null ? effort.toFixed(2) : ""}
180+
</TableCell>
179181
<TableCell sx={{ fontSize: "0.9rem" }}>{event.time}</TableCell>
180182
<TableCell sx={{ fontSize: "0.9rem" }}>
181183
{isCancelled && (

src/types/Event.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
* @property {string} distance - The planned distance of the event.
1313
* @property {string} ascent - The ascent of the event.
1414
* @property {string} time - The time taken to finish the event.
15+
* @property {string} time_limit - The cutoff time limit for the event.
16+
* @property {string} average_hr - Average heart rate during the event.
17+
* @property {string} max_hr - Maximum heart rate during the event.
1518
* @property {string} link - URL to event website.
1619
* @property {Tags} tags - An array of tags used to filter events.
1720
* @property {string} type - The category event.
@@ -31,6 +34,9 @@ export interface Event {
3134
distance: string;
3235
ascent?: string;
3336
time: string;
37+
time_limit?: string;
38+
average_hr?: string;
39+
max_hr?: string;
3440
link: string;
3541
tags: Tags;
3642
type: string;

0 commit comments

Comments
 (0)