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
Expand Up @@ -2,6 +2,7 @@ package com.eatssu.android.data.remote.dto.response

import com.eatssu.android.domain.model.ReviewInfo
import com.google.gson.annotations.SerializedName
import kotlin.math.round

data class MealReviewInfoResponse(
@SerializedName("menuNames") val menuNames: List<String>? = null,
Expand All @@ -21,7 +22,7 @@ data class MealReviewInfoResponse(

fun MealReviewInfoResponse.toDomain() = ReviewInfo(
reviewCnt = totalReviewCount ?: 0,
rating = rating ?: 0.0,
rating = (round((rating ?: 0.0) * 10) / 10),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

평점을 소수점 첫째 자리까지 반올림하는 로직이 MenuReviewInfoResponse.kt 파일에서도 동일하게 사용되고 있습니다. 코드 중복을 줄이고 가독성을 높이기 위해, 이 로직을 별도의 유틸리티 함수로 추출하여 사용하는 것을 고려해보시는 것이 좋겠습니다.

또한, 현재 구현 방식 대신 String.format을 사용하여 반올림을 처리하면 의도를 더 명확하게 표현할 수 있습니다. 아래 제안된 코드는 내부적으로 RoundingMode.HALF_UP을 사용하여 반올림을 수행하며, 코드를 더 직관적으로 만들어줍니다.

Suggested change
rating = (round((rating ?: 0.0) * 10) / 10),
rating = String.format("%.1f", rating ?: 0.0).toDouble(),

oneStarCount = reviewRatingCount?.oneStarCount ?: 0,
twoStarCount = reviewRatingCount?.twoStarCount ?: 0,
threeStarCount = reviewRatingCount?.threeStarCount ?: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.eatssu.android.data.remote.dto.response

import com.eatssu.android.domain.model.ReviewInfo
import com.google.gson.annotations.SerializedName
import kotlin.math.round

data class MenuReviewInfoResponse(
@SerializedName("menuName") val menuName: String? = null,
Expand All @@ -21,7 +22,7 @@ data class MenuReviewInfoResponse(

fun MenuReviewInfoResponse.toDomain() = ReviewInfo(
reviewCnt = totalReviewCount ?: 0,
rating = rating ?: 0.0,
rating = (round((rating ?: 0.0) * 10) / 10),
oneStarCount = reviewRatingCount?.oneStarCount ?: 0,
twoStarCount = reviewRatingCount?.twoStarCount ?: 0,
threeStarCount = reviewRatingCount?.threeStarCount ?: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ fun ReviewNav(
val reviewId = prev?.get<Long>("reviewId") ?: 0L
val initialRating = prev?.get<Int>("initialRating") ?: 0
val initialContent = prev?.get<String>("initialContent") ?: ""
val menuLikeInfoNames =
prev?.get<ArrayList<Review.MenuLikeInfo>>("menuList") ?: arrayListOf()
val menuLikeInfoNames = prev?.get<List<Review.MenuLikeInfo>>("menuList")
?.let { ArrayList(it) } ?: arrayListOf()

ModifyReviewScreen(
reviewId = reviewId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.eatssu.android.presentation.mypage.myreview

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand Down Expand Up @@ -38,6 +39,7 @@ import com.eatssu.common.UiEvent
import com.eatssu.common.UiState
import com.eatssu.design_system.component.EatSsuTopBar
import com.eatssu.design_system.theme.EatssuTheme
import com.eatssu.design_system.theme.Gray100
import com.eatssu.design_system.theme.Gray600
import timber.log.Timber

Expand Down Expand Up @@ -114,8 +116,7 @@ internal fun MyReviewListScreen(
Surface(modifier = modifier.padding(innerPadding)) {
Column(
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 24.dp),
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
) {

Expand All @@ -127,7 +128,9 @@ internal fun MyReviewListScreen(
val reviewList = dataState.myReviews ?: emptyList()

LazyColumn(
modifier = Modifier.weight(1f)
modifier = Modifier
.weight(1f)
.padding(horizontal = 24.dp),
) {
items(reviewList) { item ->
ReviewItem(
Expand All @@ -150,7 +153,9 @@ internal fun MyReviewListScreen(
is MyReviewState.NoReview -> {
Timber.d("리뷰 없음")
Column(
modifier = Modifier.fillMaxSize(),
modifier = Modifier
.fillMaxSize()
.background(Gray100),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ fun MyReviewNav(
val reviewId = prev?.get<Long>("reviewId") ?: 0L
val initialRating = prev?.get<Int>("initialRating") ?: 0
val initialContent = prev?.get<String>("initialContent") ?: ""
val menuLikeInfoNames =
prev?.get<ArrayList<Review.MenuLikeInfo>>("menuList") ?: arrayListOf()
val menuLikeInfoNames = prev?.get<List<Review.MenuLikeInfo>>("menuList")
?.let { ArrayList(it) } ?: arrayListOf()

ModifyReviewScreen(
reviewId = reviewId,
Expand Down