Skip to content

Commit

Permalink
Change how answer are parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
JcMinarro committed Oct 23, 2024
1 parent 897afd7 commit 13e82e2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,7 @@ internal fun DownstreamPollDto.toDomain(currentUserId: UserId?): Poll {
.values
.toList()

val answer = (
(
latest_votes_by_option
?.values
?.flatten()
?.filter { it.is_answer == true }
?.map { it.toAnswerDomain(currentUserId) }
?: emptyList()
) +
own_votes
.filter { it.is_answer == true }
.map { it.toAnswerDomain(currentUserId) }
)
.associateBy { it.id }
.values
.toList()
val answer = latest_answers?.map { it.toAnswerDomain(currentUserId) } ?: emptyList()

return Poll(
id = id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ internal data class DownstreamPollDto(
val options: List<DownstreamOptionDto>,
val vote_counts_by_option: Map<String, Int>?,
val latest_votes_by_option: Map<String, List<DownstreamVoteDto>>?,
val latest_answers: List<DownstreamVoteDto>?,
val created_at: Date,
val created_by: DownstreamUserDto,
val created_by_id: String,
Expand Down

0 comments on commit 13e82e2

Please sign in to comment.