Skip to content

Commit

Permalink
Update poll threshold formula
Browse files Browse the repository at this point in the history
  • Loading branch information
Delemangi committed Nov 12, 2023
1 parent ce285d3 commit 25c79fa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/utils/polls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ export const getPollThreshold = async (pollId: string) => {
}

const totalVoters = await getMembersWithRoles(guild, ...poll.roles);
const rawThreshold = totalVoters.length * poll.threshold;
const abstenstions = await countPollVotesByOptionId(
poll.options.find((option) => option.name === "Воздржан")?.id ?? "",
);
const rawThreshold =
(totalVoters.length - (abstenstions ?? 0)) * poll.threshold;
const threshold = Number.isInteger(rawThreshold)
? rawThreshold + 1
: Math.ceil(rawThreshold);
Expand All @@ -169,11 +173,7 @@ export const getPollThreshold = async (pollId: string) => {
return threshold;
}

const abstenstions = await countPollVotesByOptionId(
poll.options.find((option) => option.name === "Воздржан")?.id ?? "",
);

return threshold - (abstenstions ?? 0);
return threshold;
};

export const decidePoll = async (pollId: string) => {
Expand Down

0 comments on commit 25c79fa

Please sign in to comment.