Skip to content

Make it possible to sync WCA results #81

Description

@mintydev789

It would be good to have a feature where you can synchronize WCA results to a RecordRanks instance in a read-only fashion, just to have them included in the rankings. Read-only means that the results cannot be edited, since the source of truth for them is the WCA, only synchronized again. The implementation of this could look something like this:

  1. Add thirdPartySource: "wca" | "cubingcontests" field to the rounds table (eventually it will also be possible to sync results from Cubing Contests). If this is equal to "wca", results may not be added, updated or deleted in that round. They can only change using the synchronization feature. This will require a migration (see scripts in package.json5).
  2. Update restriction for WCA events in the WCA competitions section in validateAndCleanUpContest(). Instead of blocking WCA events altogether, it should require that all rounds for those events have thirdPartySource: "wca". Ideally, it should be possible to set an event to only permit synchronization from one of the third party sources.
  3. Add a "Sync third-party rounds" button to the top of the edit contest page when the contest type is WCA. This should fetch the rounds from the WCA API (not sure what the endpoint is for this; maybe the results endpoint also includes this information), convert them to an RR-compatible list of rounds, with each round having thirdPartySource: "wca", and save them. This button should only be visible when the contest state is created (before approval). This should be done in a new contests server function. The feature should be admin-only (the server function can check for the contest approve permission).
  4. Add a "Sync results" button in the same place. This should fetch data from www.worldcubeassociation.org/api/v0/competitions/[competitionId]/results, convert it to an RR-compatible list of results, with each result linked to the correct round in the RR DB, and save them. This button should only be visible when the contest state is approved (before ongoing). For now, it should only be possible to sync the results once (re-sync functionality should be added later). If it's detected that any wca event round for the contest already has a result, the sync should be stopped (an error should be thrown). The sync process should be done in a drizzle transaction in a new results server function. The feature should be admin-only (the server function can check for the contest approve permission).
  5. Block data entry for thirdPartySource !== null rounds on the data entry page. Display this message at the top: "This round was synchronized from a third-party source. Data entry is restricted."

Note, this process is a bit manual for now, but this lays the groundwork to have it functional, making it possible to automate it further later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions