Skip to content

Preview site: every runner and result here is made up, and it can be reset at any time.

Pub Runners.

Developers

The timer app

All developer pages · From docs/timer.md in the release that is running.

The club timing app, ported from the Google Apps Script backend to the pub-runners.com API. The screens, styles and route map are kept from the original; what changed is where the data comes from and how it is saved.

It is a static app in public/timer, served from https://pub-runners.com/timer. The site serves index.html with a Content Security Policy that only allows requests to the site itself and map tiles from OpenStreetMap.

What changed from the Apps Script version

Before (Apps Script) Now (pub-runners.com API)
A shared club code in config.js Timers are hosts signed in on pub-runners.com (/timer/sign-in). Participants join tonight's run with the club's join code (1901 unless a host changes it), which the timer shows, or the link /timer/?join=CODE.
One phone claims the timer role Any signed-in host can time, and another host can take over if a phone dies. Taps from both count.
Every tap waits for a request Each tap is an event with a UUID made on the phone. It goes into a queue in browser storage and is resent until the server accepts it. The screen updates straight away.
The full name list goes to every phone Participants search with three or more letters and get ten matches at most. Timers get the full roster with predicted times.
Routes in routes.js and a routes/ folder The route comes from the run: route_gpx_url from the API.
Times written to the sheet, and a CSV Results are built on the site ("Build the results"). A host checks and publishes them in the admin.
Pairs set up in the sheet "Several finishing together" puts up to 10 people in one finish.
Fixes overwrite the data Fixes are more events (void, self_reported, assign), so the full history is kept.

How each action maps to the API

Screen action API
Check in (participant) POST /api/v1/participant/join, then POST /participant/checkin
Start my run (late) POST /participant/start (server clock)
Not you? DELETE /participant/checkin
Open tonight POST /api/v1/timing/runs/tonight
Show the code GET /timing/join-code
Change the code PATCH /timing/join-code
Start, finish, end, back, late start gun, finish, end, back and start events
Unchecked runner, then name them finish with no runners, then assign
Undo, remove, resume void of the event in question
Fix a time self_reported with the seconds
Swap times void both finishes, then two finish events at the same moments, swapped
Change type attendance (walked, pubbed, timed), or void it to make them a runner again
Build the results POST /timing/runs/{id}/finalise (force for "ran, no time")
Live screen GET /timing/runs/{id}/state every 4 seconds with If-None-Match

Not ported yet

  • Renaming someone: the only renaming kept is naming an unchecked runner. Fix wrong names in the admin.
  • QR code: the timer shows the code and a link instead.
  • Offline install: there is no service worker.

Developing

See Contributing (CONTRIBUTING.md): change the files in public/timer, open a pull request, and try it on the pull request's preview site.