Skip to content

Commit

Permalink
Fix competition issue (#464)
Browse files Browse the repository at this point in the history
* Fix competition issue

* bump version
  • Loading branch information
ben-kaufman committed Feb 4, 2020
1 parent 7a1e866 commit 5141403
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@daostack/subgraph",
"version": "0.0.37-2",
"version": "0.0.37-3",
"author": "DAOstack (https://www.daostack.io)",
"license": "GPL-3.0",
"description": "A caching layer for daostack using The Graph",
Expand Down
8 changes: 4 additions & 4 deletions src/mappings/Competition/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,23 +156,23 @@ export function handleNewVote(event: NewVote): void {
return 1;
}
});
let lastTotalVotes = BigInt.fromI32(0);
let lastTotalWinnerVotes = BigInt.fromI32(0);
let idx = BigInt.fromI32(0);
for (let i = 0; i < suggestions.length; i++) {
let competitionSuggestion = CompetitionSuggestion.load(suggestions[i] as string);
if (lastTotalVotes.gt(competitionSuggestion.totalVotes)) {
if (lastTotalWinnerVotes.gt(competitionSuggestion.totalVotes)) {
idx = idx.plus(BigInt.fromI32(1));
}
if ((lastTotalVotes.notEqual(competitionSuggestion.totalVotes) &&
if ((lastTotalWinnerVotes.notEqual(competitionSuggestion.totalVotes) &&
idx >= competitionProposal.numberOfWinners) ||
competitionSuggestion.totalVotes.equals(BigInt.fromI32(0))) {
competitionSuggestion.positionInWinnerList = null;
} else {
competitionSuggestion.positionInWinnerList = idx;
winningSuggestions.push(competitionSuggestion.id as string);
lastTotalWinnerVotes = competitionSuggestion.totalVotes;
}
competitionSuggestion.save();
lastTotalVotes = competitionSuggestion.totalVotes;
}
competitionProposal.winningSuggestions = winningSuggestions;
competitionProposal.save();
Expand Down

0 comments on commit 5141403

Please sign in to comment.