Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.wire.apps.polls.dto

import com.wire.apps.polls.services.VoteDisplay
import kotlin.math.roundToInt

data class PollVoteCountProgress(
val totalVoteCount: Int,
val totalMembers: Int
Expand All @@ -16,13 +13,10 @@ data class PollVoteCountProgress(
fun new(): String = initial().display()
}

fun display(): String {
val percent = if (totalMembers > 0) totalVoteCount.toDouble() / totalMembers else 0.0
val voteDisplay = VoteDisplay((percent * BLOCKS).roundToInt(), BLOCKS)
val percentDisplay = (percent * PERCENTAGE_FACTOR).roundToInt()

return "$voteDisplay $percentDisplay%"
}
/**
* Percentage voting blocked until WPB-27239 is done
*/
fun display(): String = "Total votes: $totalVoteCount"

fun everyoneVoted() = (totalVoteCount == totalMembers)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.wire.apps.polls.dto.common.Text
import io.github.oshai.kotlinlogging.KotlinLogging
import pw.forst.katlib.newLine
import pw.forst.katlib.whenNull
import kotlin.math.min

class StatsFormattingService(
private val repository: PollRepository
Expand Down Expand Up @@ -71,6 +70,7 @@ class StatsFormattingService(
* - ⬛⬛⬛ A (3)
* - ⬜⬜⬜ B (1)
*/
@Suppress("UnusedParameter")
private fun formatVotes(
stats: Map<Pair<Int, String>, Int>,
conversationMembers: Int
Expand All @@ -79,10 +79,8 @@ class StatsFormattingService(
val mostPopularOptionVoteCount =
requireNotNull(stats.values.maxOrNull()) { "There were no stats!" }

val maximumSize = min(
conversationMembers,
mostPopularOptionVoteCount + MAX_VOTE_PLACEHOLDER_COUNT
)
// Percentage voting blocked until WPB-27239 is done
val maximumSize = mostPopularOptionVoteCount

return stats
.map { (option, votingUsers) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource
import kotlin.test.Ignore

@Ignore("Percentage voting blocked until WPB-27239 is done")
class StatsFormattingServiceTest {
val pollRepository = mockk<PollRepository>()

Expand Down