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:
parent
8cb83050ac
commit
cf782f039f
8 changed files with 60 additions and 30 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue