-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix poll fraction calculation for Pleroma #284
base: master
Are you sure you want to change the base?
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.votersCount
equals1
for polls. So let's just usepoll.votesCount
as total value for fraction calculation.