Skip to content

Commit 3cd0d1a

Browse files
committed
new preferential function
1 parent a2a4133 commit 3cd0d1a

File tree

3 files changed

+220
-235
lines changed

3 files changed

+220
-235
lines changed

apps/server/src/room/interaction/db/questions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { QuestionResponse, ResultsView } from "../../../live/question";
66
import type { VotingCandidate } from "../../../live/states";
77
import { UnreachableError } from "../../../unreachableError";
88
import type { CreateQuestionParams, QuestionFormatDetails } from "../../types";
9-
import { rankedChoiceVoting } from "../preferentialVote";
9+
import { rankedElection } from "../preferentialVote";
1010
import type { CloseQuestionDetails, DbQuestionData } from "./queries";
1111
import {
1212
dbCloseQuestion,
@@ -117,13 +117,13 @@ function mapDbQuestionData(question: DbQuestionData): RoomQuestion {
117117
(candidate) => candidate.id,
118118
);
119119

120-
const resultIds = rankedChoiceVoting(
120+
const { elected } = rankedElection(
121121
candidateIds,
122122
votingPreferences,
123123
question.maxElected,
124124
); // get the result in order of preference
125125

126-
const results = resultIds.map((c, index) => ({
126+
const results = elected.map((c, index) => ({
127127
id: c.id,
128128
// biome-ignore lint/style/noNonNullAssertion: Known keys
129129
name: question.candidates.find((candidate) => candidate.id === c.id)

apps/server/src/room/interaction/preferentialVote.test.ts

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)