use number of voters instead of votes to calculate poll results (#1733)

* adjust poll vote text, votes -> people

* use number of voters instead of votes to calculate poll results

* fix tests
This commit is contained in:
Konrad Pozniak 2020-03-24 21:06:58 +01:00 committed by GitHub
commit cf782f039f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 60 additions and 30 deletions

View file

@ -9,6 +9,7 @@ data class Poll(
val expired: Boolean,
val multiple: Boolean,
@SerializedName("votes_count") val votesCount: Int,
@SerializedName("voters_count") val votersCount: Int?, // nullable for compatibility with Pleroma
val options: List<PollOption>,
val voted: Boolean
) {
@ -22,7 +23,12 @@ data class Poll(
}
}
return copy(options = newOptions, votesCount = votesCount + choices.size, voted = true)
return copy(
options = newOptions,
votesCount = votesCount + choices.size,
votersCount = votersCount?.plus(1),
voted = true
)
}
fun toNewPoll(creationDate: Date) = NewPoll(