Skip to content

Commit 612bbb5

Browse files
committed
throw an error and remove impl
1 parent bde582f commit 612bbb5

File tree

4 files changed

+2
-453
lines changed

4 files changed

+2
-453
lines changed

apps/server/src/live/question.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { TypeOf } from "zod";
22
import { z } from "zod";
33
import type { QuestionFormat } from "../dbschema/interfaces";
4-
import type { RoundRecord } from "../room/interaction/preferentialVote";
54

65
const singleVoteType = "SingleVote" satisfies QuestionFormat;
76

@@ -67,7 +66,6 @@ export interface SingleVoteResultsView {
6766
export interface PreferentialVoteResultsView {
6867
type: typeof preferentialVoteType;
6968
results: CandidateWithRank[];
70-
records: RoundRecord[]
7169
}
7270

7371
export type ResultsView = { abstained: number } & (

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

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ 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 { STVElection } from "../preferentialVote";
109
import type { CloseQuestionDetails, DbQuestionData } from "./queries";
1110
import {
1211
dbCloseQuestion,
@@ -106,37 +105,14 @@ function mapDbQuestionData(question: DbQuestionData): RoomQuestion {
106105
});
107106
}
108107

109-
const votingPreferences = Object.entries(voterAndCandidateRank).map(
108+
const _votingPreferences = Object.entries(voterAndCandidateRank).map(
110109
([_voterId, votes]) => {
111110
const sortedVotes = votes.sort((a, b) => a.rank - b.rank); // sort by preference
112111
return sortedVotes.map((vote) => vote.candidateId);
113112
},
114113
);
115114

116-
const election = new STVElection()
117-
118-
for (const prefs of votingPreferences) {
119-
election.addBallot(prefs);
120-
}
121-
122-
const { elected, records } = election.runElection(question.maxElected);
123-
124-
const results = elected.map((c, index) => ({
125-
id: c,
126-
name:
127-
question.candidates.find(
128-
(candidate) => candidate.id === c,
129-
)?.name || "Unknown Candidate",
130-
rank: index + 1,
131-
votes: records[records.length - 1]?.voteTotals[c] || 0,
132-
}));
133-
134-
return {
135-
type: "PreferentialVote",
136-
results,
137-
records,
138-
abstained: abstainCount,
139-
};
115+
throw new Error("STV Election not implemented"); // TODO: Implement STV counting and results formatting
140116
}
141117
default:
142118
throw new UnreachableError(question.format);

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

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

0 commit comments

Comments
 (0)