Skip to content

Commit

Permalink
Competition ties (daostack#453)
Browse files Browse the repository at this point in the history
* Fix competition ties handling

* Fix

* Fix

* Revert "Fix"

This reverts commit 5fe0be0.

* Fix

* Bump version
  • Loading branch information
ben-kaufman authored and shekhar-shubhendu committed Mar 9, 2020
1 parent c7f33e6 commit e3f3dbd
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
39 changes: 39 additions & 0 deletions daos/private/testdao38.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "Mannered Model",
"Avatar": "0xB4338a1DAEf80472C9a8041c3dEE03239a8a5ec0",
"DAOToken": "0x36BA4e706327BC6bcdd5511f5799A7F46d0dA5Ad",
"Reputation": "0x7e075b685A85492d335082bF12EE7CCD06A2b15c",
"Controller": "0x30553AE4b803DbDDc8873d5Fc972e0fBfbDaE46D",
"Schemes": [
{
"name": "GenericScheme",
"alias": "GenericSchemeAlias",
"address": "0x620610Cb5e4a3e2439807682DbE92246Dc256cE3",
"arcVersion": "0.0.1-rc.38"
},
{
"name": "ContributionRewardExt",
"alias": "ContributionRewardExt",
"address": "0x97d3dB2767855540b5e290E4Fa931950853875F8",
"arcVersion": "0.0.1-rc.38"
}
],
"StandAloneContracts": [
{
"name": "Wallet",
"address": "0x4f89E1754c066e79b30954ED0FFE0AD173D63250",
"arcVersion": "0.0.1-rc.38"
},
{
"name": "ContributionRewardExt",
"address": "0x97d3dB2767855540b5e290E4Fa931950853875F8",
"arcVersion": "0.0.1-rc.38"
},
{
"name": "Competition",
"address": "0xb30796E3d96aA720F7c478e32eCD8a7c97335f54",
"arcVersion": "0.0.1-rc.38"
}
],
"arcVersion": "0.0.1-rc.38"
}
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.36-9",
"version": "0.0.36-10",
"author": "DAOstack (https://www.daostack.io)",
"license": "GPL-3.0",
"description": "A caching layer for daostack using The Graph",
Expand Down
10 changes: 6 additions & 4 deletions src/mappings/Competition/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,19 @@ export function handleNewVote(event: NewVote): void {
let idx = BigInt.fromI32(0);
for (let i = 0; i < suggestions.length; i++) {
let competitionSuggestion = CompetitionSuggestion.load(suggestions[i] as string);
if (idx >= competitionProposal.numberOfWinners ||
if (lastTotalVotes.gt(competitionSuggestion.totalVotes)) {
idx = idx.plus(BigInt.fromI32(1));
}
if ((lastTotalVotes.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);
}
competitionSuggestion.save();
if (lastTotalVotes.lt(competitionSuggestion.totalVotes)) {
idx = idx.plus(BigInt.fromI32(1));
}
lastTotalVotes = competitionSuggestion.totalVotes;
}
competitionProposal.winningSuggestions = winningSuggestions;
competitionProposal.save();
Expand Down

0 comments on commit e3f3dbd

Please sign in to comment.