@netvote/elections-tally
Tally Netvote Elections
Last updated 2 years ago by netvote-steven .
GPL-3.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @netvote/elections-tally 
SYNC missed versions from official npm registry.

Netvote Tally Library

Build Status

Logo

Library and CLI for tallying elections

Example Usage:

const tally = require('@netvote/elections-tally');

tally.tallyElection({
    electionAddress: '0xabcd9ebf41456077e2074d66d68e2aeb1286be4b',
    provider: 'https://ropsten.infura.io',
    resultsUpdateCallback: (resultsStatusObj) => {
        
        // Update UI progress indicators (graphs/etc)
        
    }
}).then((finalResults) => {
    
    // Tallying complete
    
}).catch((err) => {
    console.error(err);
});

Example Results Status Object

// pool 0 of 15
// voter 3 of 48748 in pool
// ballot 2 of 3
resultsStatusObj = {
    "status": "tallying",
    "progress": {
        "poolIndex": 0,           //current pool index
        "poolTotal": 15,          //total pools
        "poolBallotIndex": 2,     //current ballot for this pool
        "poolBallotTotal": 3,     //total ballots for pool
        "poolVoterIndex": 3,      //index of voter for this pool
        "poolVoterTotal": 48748   //total voters for this pool
    },
    "results": {
      // current results object
    }
}

Example Results

finalResults = {
    "election": "0xabcdea541751984aa3e5fd9a1ba3a12e4ba04a23",
    "ballots": {
        "0xabcdea541751984aa3e5fd9a1ba3a12e4ba04a23": {
            "ballotTitle": "2020 NYC Election",
            "totalVotes": 3236,
            "decisionMetadata": [
                {
                    "sectionTitle": "Mayor",
                    "sectionTitleNote": "",
                    "ballotItems": [
                        {
                            "itemTitle": "John Doe",
                            "itemDescription": "..."
                        },
                        {
                            "itemTitle": "Sally Thomas",
                            "itemDescription": "..."
                        }
                    ]
                }
            ],
            "results": {
                "ALL": [
                    {
                        "John Doe": 1001,
                        "Sally Thomas": 2231,
                        "WRITEIN-SARAH WILLIAMS": 4
                    }
                ]
            }
        }
    }
}

Contributing

Contribution Process

  1. Fork repo
  2. Make desired changes
  3. Submit PR (Reference Issue #)
  4. Reviewer will review
  5. Reviewer Squash + Merges PR

License

All code is released under the GNU General Public License v3.0.

Current Tags

  • 0.2.13                                ...           latest (2 years ago)

14 Versions

  • 0.2.13                                ...           2 years ago
  • 0.2.12                                ...           2 years ago
  • 0.2.11                                ...           2 years ago
  • 0.2.10                                ...           2 years ago
  • 0.2.9                                ...           2 years ago
  • 0.2.8                                ...           2 years ago
  • 0.2.7                                ...           2 years ago
  • 0.2.6                                ...           2 years ago
  • 0.2.5                                ...           2 years ago
  • 0.2.4                                ...           2 years ago
  • 0.2.3                                ...           2 years ago
  • 0.2.2                                ...           2 years ago
  • 0.2.1                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 5
Dependencies (10)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |