mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
calculate percent with voters instead votes
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
a8afb61745
commit
3b4be83ea7
@ -33,8 +33,7 @@ data class Poll(
|
||||
val maxVotes: Int,
|
||||
val votedSelf: List<Int>?,
|
||||
val numVoters: Int,
|
||||
val details: List<PollDetails>?,
|
||||
val totalVotes: Int
|
||||
val details: List<PollDetails>?
|
||||
) {
|
||||
companion object {
|
||||
const val STATUS_OPEN: Int = 0
|
||||
|
@ -133,8 +133,7 @@ class PollRepositoryImpl(private val ncApi: NcApi, private val currentUserProvid
|
||||
pollResponse.maxVotes,
|
||||
pollResponse.votedSelf,
|
||||
pollResponse.numVoters,
|
||||
pollDetails,
|
||||
getTotalVotes(pollResponse.votes)
|
||||
pollDetails
|
||||
)
|
||||
}
|
||||
|
||||
@ -154,13 +153,5 @@ class PollRepositoryImpl(private val ncApi: NcApi, private val currentUserProvid
|
||||
pollDetailsResponse.optionId,
|
||||
)
|
||||
}
|
||||
|
||||
private fun getTotalVotes(votes: Map<String, Int>?): Int {
|
||||
var totalVotes = 0
|
||||
votes?.forEach {
|
||||
totalVotes += it.value
|
||||
}
|
||||
return totalVotes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class PollResultsViewModel @Inject constructor() : ViewModel() {
|
||||
private fun initPollResults(poll: Poll) {
|
||||
_items.value = ArrayList()
|
||||
|
||||
val oneVoteInPercent = HUNDRED / poll.totalVotes
|
||||
val oneVoteInPercent = HUNDRED / poll.numVoters
|
||||
|
||||
poll.options?.forEachIndexed { index, option ->
|
||||
val votersAmountForThisOption = getVotersAmountForOption(poll, index)
|
||||
|
Loading…
Reference in New Issue
Block a user