liquidvotingio / decidim-module-liquidvoting

GNU Affero General Public License v3.0
4 stars 0 forks source link

Create/delete delegation do not update the vote count #94

Closed davefrey closed 3 years ago

davefrey commented 3 years ago

All four of the api mutations, (create|delete)_(vote|delegation), can alter the number of votes for a proposal. Currently, only the vote mutators are updating the proposals.proposal_vote_count which is displayed in the interface as "nnn Supports". But delegations affect the count as well when the delegate has already voted: the number of votes for a proposal will increase by the weight of the delegator (their own vote + any delegations naming them as delegate).

In the case of create_delegation, the ApiClient (and apparently the api itself, see liquidvotingio/api#189) return true instead of a response containing a voting_result.

In the case of delete_delegation, there is a response containing a voting_result returned to the client, but our module code does not extract the new vote count and save it in the proposal.

jinjagit commented 3 years ago

votingResult can definitely be returned for (create|delete)_(vote|delegation) in the current api PR #227 I am working on, though I am not sure this was working correctly before (it probably was). The votingResult query has to be present in the absinthe mutation operation(s), of course.

jinjagit commented 3 years ago

e.g: (note: votingMethod is not a valid field for mutations or queries in the current deployed api) create_del delete_del create_vote delete_vote

davefrey commented 3 years ago

Oh this is excellent, thank you! It's not the api that is the problem but the parsed graphql query in api_client.rb in our module that specifies the return value. Today it's only returning the :id but I can change that to be a votingResult, then I can parse and return the suitable thing from the ApiClient 😀

I'll close the related issue liquidvotingio/api#189 I don't think we need anything in that repo.