thewca / wca-live

Platform for running WCA competitions and sharing live results with the world
https://live.worldcubeassociation.org
70 stars 23 forks source link

More predictable URLs #230

Closed timreyn closed 1 month ago

timreyn commented 2 months ago

e.g. https://live.worldcubeassociation.org/competitions/4824/competitors/564765 https://live.worldcubeassociation.org/competitions/4824/rounds/65427

4824, 564765, and 65427 are WCA Live-internal IDs.

It would be great if WCA Live used predictable URLs that other software can generate, so that e.g. nametags can have QR codes pointing to your personal results page. For example:

https://live.worldcubeassociation.org/competitions/MissouriChampionship2024/competitors/2022CHAI02 [using their wcaId] https://live.worldcubeassociation.org/competitions/MissouriChampionship2024/competitors/7 [using their wcaRegistrantId] https://live.worldcubeassociation.org/competitions/MissouriChampionship2024/rounds/333/1

This can be done in a backwards-compatible way -- the URL could accept both the WCA Live ID and the competition ID, as it's essentially impossible for these to overlap.

jonatanklosko commented 2 months ago

We actually already support such links to competitions and rounds:

https://github.com/thewca/wca-live/blob/9ffd91212e1085b8722614221f9028730211a7f1/lib/wca_live_web/router.ex#L42-L43

So this works: https://live.worldcubeassociation.org/link/competitions/MissouriChampionship2024/rounds/333/1

Those are redirects, which I consider preferable, otherwise it requires special handling all around.

We can add /link/competitions/:wca_id/competitors/:wca_registrant_id. It can be :wca_id_or_wca_registrant_id, except I'm not sure how useful this is given that not everyone may have WCA ID (especially if it's an external tool that would generate it).

timreyn commented 2 months ago

Oh awesome!

There is some advantage to those being the canonical URLs, rather than redirects, for discoverability and clarity when a URL is shared -- if someone sends me a URL with the internal IDs I don't know what it's for. But that's less important than the links existing.

I think that would be great! Having the WCA IDs would make the links more readable -- it'll allow humans to construct those links (rather than just software with access to WCIF), and for me to know what a link is before clicking on it.

jonatanklosko commented 2 months ago

There is some advantage to those being the canonical URLs

Yeah, it's a tradeoff. Technically lookups are less efficient because to resolve 333-r1 we need to join on the competition and competition event (or duplicate the corresponding ids in each round row). Either way, I don't think it's worth the necessary changes at the moment, so I would stick to redirects.

One possible middle ground would be to have a share button in the relevant places that copies the human friendly link into clipboard (for discoverability).

jonatanklosko commented 1 month ago

I added redirects for the competitor page in a7feb2faa04dded59bfd1452826e783f02b77ae1. So these work now:

https://live.worldcubeassociation.org/link/competitions/MissouriChampionship2024/competitors/2022CHAI02 https://live.worldcubeassociation.org/link/competitions/MissouriChampionship2024/competitors/7