Skip to content

Commit d9a61c2

Browse files
alcercujaybuidl
authored andcommitted
fix(subgraph): incorrect totalVoted on ClassicRound
1 parent 0da521f commit d9a61c2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

subgraph/core/src/entities/ClassicRound.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ class CurrentRulingInfo {
2525
tied: boolean;
2626
}
2727

28-
export function updateCountsAndGetCurrentRuling(id: string, choice: BigInt, choiceCount: BigInt): CurrentRulingInfo {
28+
export function updateCountsAndGetCurrentRuling(id: string, choice: BigInt, delta: BigInt): CurrentRulingInfo {
2929
const round = ClassicRound.load(id);
3030
if (!round) return { ruling: ZERO, tied: false };
3131
const choiceNum = choice.toI32();
32-
const delta = choiceCount.minus(round.counts[choiceNum]);
32+
const newChoiceCount = round.counts[choiceNum].plus(delta);
3333
let newCounts: BigInt[] = [];
3434
for (let i = 0; i < round.counts.length; i++) {
3535
if (BigInt.fromI32(i).equals(choice)) {
36-
newCounts.push(choiceCount);
36+
newCounts.push(newChoiceCount);
3737
} else {
3838
newCounts.push(round.counts[i]);
3939
}
@@ -43,9 +43,9 @@ export function updateCountsAndGetCurrentRuling(id: string, choice: BigInt, choi
4343
if (choice.equals(round.winningChoice)) {
4444
if (round.tied) round.tied = false;
4545
} else {
46-
if (choiceCount.equals(currentWinningCount)) {
46+
if (newChoiceCount.equals(currentWinningCount)) {
4747
if (!round.tied) round.tied = true;
48-
} else if (choiceCount.gt(currentWinningCount)) {
48+
} else if (newChoiceCount.gt(currentWinningCount)) {
4949
round.winningChoice = choice;
5050
round.tied = false;
5151
}

0 commit comments

Comments
 (0)