Skip to content

Handle missing proposal vote counts#229

Open
optimystical wants to merge 1 commit into
effectai:mainfrom
optimystical:fix-missing-vote-counts
Open

Handle missing proposal vote counts#229
optimystical wants to merge 1 commit into
effectai:mainfrom
optimystical:fix-missing-vote-counts

Conversation

@optimystical

Copy link
Copy Markdown

Summary

Fixes the proposal vote percentage calculation when older proposals have sparse vote_counts entries.

Root cause

Older proposals may omit vote count entries for vote types that received no votes. The proposal detail page assumed proposal.vote_counts[0], [1], and [2] were always present, so opening those proposals could throw when one vote type was missing.

Fix

The percentage calculation now sums the value fields for whichever vote count entries are present, and returns 0.00 when the total is zero.

Fixes #184.

Validation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

First proposal doesn't show votes

1 participant