fraz3alpha / running-challenges

An extension to allow you to complete challenges with your parkrun results
Other
36 stars 20 forks source link

Record Breaker table broken if no average event #398

Open LukeWoodward opened 1 year ago

LukeWoodward commented 1 year ago

If a parkrunner has no average event (e.g. they have only run at junior events or at events now closed), the Record Breaker table doesn't appear properly. A broken image appears and the table of events is empty:

image

There is also an error Failed to load resource: net::ERR_FILE_NOT_FOUND for "runner-record-breaker.png" in developer tools.

If you click on the 'show map' text in the above screenshot, the map appears, with no annotations, but you also get a JavaScript error Uncaught TypeError: Cannot read properties of undefined (reading 'lat') in developer tools.

The quickest fix to this is to not add the record-breaker challenge data if there is no event location data. This could be done by adding the condition data.parkrun_results.some(result => result.name in data.geo_data.data.events) to line 251 of challenges.js. This will cause the extension to no longer show the Record Breaker table. However, I don't know whether you would also want some text on the page explaining why the Record Breaker table is missing.