Skip to content

Commit

Permalink
fix: Missing choice in csv (#198)
Browse files Browse the repository at this point in the history
* fix: Missing choice in csv

* Remove logs

* Fix

* Add tests for ranked choice

* Lint

* Add tests for approval and quadratic

* lint
  • Loading branch information
ChaituVR authored Oct 24, 2023
1 parent 120ea2d commit 643f447
Show file tree
Hide file tree
Showing 11 changed files with 10,304 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/lib/votesReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,14 @@ class VotesReport extends Cache {

if (typeof vote.choice !== 'number' && this.proposal) {
choices = Array.from({ length: this.proposal.choices.length });
for (const [key, value] of Object.entries(vote.choice)) {
choices[parseInt(key) - 1] = value;
if (Array.isArray(vote.choice)) {
vote.choice.forEach((value, index) => {
choices[index] = value;
});
} else {
for (const [key, value] of Object.entries(vote.choice)) {
choices[parseInt(key) - 1] = value;
}
}
} else {
choices.push(vote.choice);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"state": "closed",
"id": "0x07387077920ce65b805bd0ba913a02ecfe63d22cac3dbaed3d97c23afd053fe2",
"author": "",
"votes": 549,
"choices": ["YES", "NO", "ABSTAIN"],
"space": { "id": "", "network": "", "settings": "" }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"state": "closed",
"id": "0xafe3a0426d4e6c645e869707f1b581765698d80c8d3e9cd37d7d3bf5e6f894e7",
"author": "",
"votes": 219,
"choices": [
"Brendan Donovan",
"Brian Watson ",
"Daniel Keller",
"Danielle Clark",
"David ",
"Ely Sandvik ",
"Erikson Herman",
"James Tunningley/Ruben Amenyogbo",
"Joshua Phelps",
"keeks",
"Lia Godoy",
"Maya Bakhai",
"Michael Gutierrez",
"Nick George",
"Nicole Tremaglio",
"Sinikiwe Stephanie Dhliwayo "
],
"space": { "id": "", "network": "", "settings": "" }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"state": "closed",
"id": "0xe5e335af87dc10206e9f0de469f64901407837d659db6703cb3ea1437056a577",
"author": "",
"votes": 243,
"choices": [
"Dr.Hash“Wesley”",
"0xpeas.eth",
"Blockpunk",
"Christian",
"Dingaling",
"Freelunchcapital",
"Andrew Kang",
"Yat Siu",
"Icedcoffee",
"Ray",
"Zagabond"
],
"space": { "id": "", "network": "", "settings": "" }
}
Loading

0 comments on commit 643f447

Please sign in to comment.