From d2bb506ef6bd343dfd586ce4f81fc25cc7e44dde Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 4 Feb 2020 06:20:18 +0000 Subject: [PATCH 1/2] Fix competition issue --- src/mappings/Competition/mapping.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mappings/Competition/mapping.ts b/src/mappings/Competition/mapping.ts index 15ead359..e6d7e322 100644 --- a/src/mappings/Competition/mapping.ts +++ b/src/mappings/Competition/mapping.ts @@ -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(); From dde46320e8fc95dff09db041dc6b77eb21525557 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 4 Feb 2020 07:07:27 +0000 Subject: [PATCH 2/2] bump version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 69546e87..10bd13f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@daostack/subgraph", - "version": "0.0.37-2", + "version": "0.0.37-3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index bd0da69d..59a50692 100644 --- a/package.json +++ b/package.json @@ -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",