Skip to content

Commit 437f9d0

Browse files
committed
[Fix] 투표 결과 비율 계산에 double 타입 적용
1 parent 6836a4d commit 437f9d0

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/main/java/com/moa/moa_server/domain/vote/dto/response/VoteOptionResultWithId.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ public record VoteOptionResultWithId(
44
Long voteId,
55
int optionNumber,
66
int count,
7-
int ratio
7+
double ratio
88
) {}

src/main/java/com/moa/moa_server/domain/vote/dto/response/result/VoteOptionResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
public record VoteOptionResult(
44
int optionNumber,
55
int count,
6-
int ratio
6+
double ratio
77
) {}

src/main/java/com/moa/moa_server/domain/vote/service/VoteResultService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ private List<ResultRaw> getResultsInternal(Vote vote) {
5454
return Stream.of(1,2)
5555
.map(option -> {
5656
int count = countMap.getOrDefault(option, 0L).intValue();
57-
int ratio = totalCount == 0 ? 0 : (int) ((count * 100.0) / totalCount);
57+
double ratio = totalCount == 0 ? 0.0 : (count * 100.0) / totalCount;
5858
return new ResultRaw(option, count, ratio);
5959
})
6060
.toList();
6161
}
6262

63-
private record ResultRaw(int optionNumber, int count, int ratio) {}
63+
private record ResultRaw(int optionNumber, int count, double ratio) {}
6464

6565
}

0 commit comments

Comments
 (0)