Skip to content

Commit 63c308b

Browse files
committed
fix: subgraph bug which has not counting missed votes
1 parent 1b22294 commit 63c308b

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

subgraph/core/src/KlerosCore.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,18 @@ export function handleNewPeriod(event: NewPeriod): void {
139139
const draw = Draw.load(draws[j].id);
140140
if (!draw) continue;
141141

142+
const juror = ensureUser(draw.juror);
143+
juror.totalResolvedVotes = juror.totalResolvedVotes.plus(ONE);
144+
142145
// Since this is a ClassicVote entity, this will only work for the Classic DisputeKit (which has ID "1").
143146
const vote = ClassicVote.load(`${round.disputeKit}-${draw.id}`);
144147

145-
if (!vote) continue;
146-
147-
const juror = ensureUser(draw.juror);
148-
juror.totalResolvedVotes = juror.totalResolvedVotes.plus(ONE);
148+
if (!vote) {
149+
// Recalculate coherenceScore
150+
juror.coherenceScore = computeCoherenceScore(juror.totalCoherentVotes, juror.totalResolvedVotes);
151+
juror.save();
152+
continue;
153+
}
149154

150155
if (vote.choice === null) continue;
151156

@@ -155,9 +160,7 @@ export function handleNewPeriod(event: NewPeriod): void {
155160
}
156161

157162
// Recalculate coherenceScore
158-
if (juror.totalResolvedVotes.gt(ZERO)) {
159-
juror.coherenceScore = computeCoherenceScore(juror.totalCoherentVotes, juror.totalResolvedVotes);
160-
}
163+
juror.coherenceScore = computeCoherenceScore(juror.totalCoherentVotes, juror.totalResolvedVotes);
161164

162165
juror.save();
163166
}

subgraph/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kleros/kleros-v2-subgraph",
3-
"version": "0.10.1",
3+
"version": "0.10.2",
44
"license": "MIT",
55
"scripts": {
66
"update:core:arbitrum-sepolia-devnet": "./scripts/update.sh arbitrumSepoliaDevnet arbitrum-sepolia core/subgraph.yaml",

0 commit comments

Comments
 (0)