Skip to content

Add Condorcet count endpoint #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 11, 2024
Merged

Add Condorcet count endpoint #282

merged 4 commits into from
Jul 11, 2024

Conversation

jb3
Copy link
Member

@jb3 jb3 commented Jul 11, 2024

Adds an endpoint, /forms/{form_id}/condorcet/{question_id} to perform a
Condorcet calculation for the newly added vote components.

Optionally, a ?winners= parameter can be specified to provide the number of
results to calculate for, defaulting to 1 winner.

The rest of the Condorcet table is provided.

An example response:

{
  "question": {
    "id": "vote-1",
    "name": "Vote for your preferred options",
    "type": "vote",
    "data": {
      "options": [
        "Dog",
        "Cat",
        "Ferret",
        "Worm",
        "Chris J Lovering"
      ]
    },
    "required": true
  },
  "winners": [
    "Chris J Lovering"
  ],
  "rest_of_table": {
    "Dog": {
      "wins": [
        "Cat",
        "Ferret"
      ],
      "losses": []
    },
    "Cat": {
      "wins": [],
      "losses": [
        "Dog",
        "Worm"
      ]
    },
    "Ferret": {
      "wins": [],
      "losses": [
        "Dog",
        "Worm"
      ]
    },
    "Worm": {
      "wins": [
        "Cat",
        "Ferret"
      ],
      "losses": []
    }
  }
}

@jb3 jb3 requested a review from ks129 as a code owner July 11, 2024 21:34
@jb3 jb3 force-pushed the jb3/features/condorcet-count branch from a40efc5 to 3b6464f Compare July 11, 2024 21:44
@jb3 jb3 merged commit 23e6be1 into main Jul 11, 2024
3 of 4 checks passed
@jb3 jb3 deleted the jb3/features/condorcet-count branch July 11, 2024 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant