Fix poll fraction calculation for Pleroma - #284
Conversation
|
This is not a good workaround |
|
Why? |
|
That is only true in the Single option polls. In a multi option poll, the number of votes is higher than the number of voteRs. Its a weird edge case, but it has to be considered as well |
|
For example only 1 user takes part in the survey with Multi option polls. He checks 2 options. |
|
I forgot to respond. But I feel like what the web interface does is best. I just forgot to check what it does |
|
But with this we have failure poll values in Pleroma. Of course if you not planed to implement separated Pleroma realisation :) |
|
You can change the calculation, depending on if the server uses plemora. Not if that works break multiple choice plemora polls though. |
|
fyi, current versions of Akkoma no longer expose votersCount for single-choice polls. But regardless the correct way to to check whether a poll is a multiple-choice or not, is to just check the diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollOptionStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollOptionStatusDisplayItem.java
index 1966c0fed..c4593265a 100644
--- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollOptionStatusDisplayItem.java
+++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollOptionStatusDisplayItem.java
@@ -54,7 +54,7 @@ public class PollOptionStatusDisplayItem extends StatusDisplayItem{
}
private void calculateResults() {
- int total=poll.votersCount>0 ? poll.votersCount : poll.votesCount;
+ int total=poll.multiple ? poll.votersCount : poll.votesCount;
if(showResults && option.votesCount!=null && total>0){
votesFraction=(float)option.votesCount/(float)total;
int mostVotedCount=0;There’s however an unrelated bug in *oma backends which may lead to |
I don't know why, but Pleroma returns
poll.votersCountequals1for polls. So let's just usepoll.votesCountas total value for fraction calculation.