Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
πŸ“Š 감정 톡계 νŽ˜μ΄μ§€ | Response μˆ˜μ • (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
moondev03 authored Aug 6, 2024
1 parent edd7721 commit 20806cf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ data class DiaryStatisticsResponseDTO(
@SerializedName("angerCount") val angerCount: Int,
@SerializedName("anxietyCount") val anxietyCount: Int,
@SerializedName("depressionCount") val depressionCount: Int,
@SerializedName("Happiness") val happiness: Int
@SerializedName("happinessCount") val happinessCount: Int,
@SerializedName("boringCount") val boringCount: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class EmotionRepositoryImpl @Inject constructor(
if(res != null){
val data = res.data
if(data != null){
val signInInfo = data.run { EmotionStatistics(angerCount, anxietyCount, depressionCount, happiness) }
val signInInfo = data.run { EmotionStatistics(angerCount, anxietyCount, depressionCount, happinessCount, boringCount) }
Result.success(signInInfo)
} else {
Result.failure(Exception("Get Emotion Statistics Failed: data is null"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package com.nabi.data.service

import com.nabi.data.model.BaseResponse
import com.nabi.data.model.auth.NicknameResponseDTO
import com.nabi.data.model.auth.SignInRequestDTO
import com.nabi.data.model.auth.SignInResponseDTO
import com.nabi.data.model.emotion.DiaryStatisticsResponseDTO
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

interface EmotionService {

@POST("/emotion/{startDate}/{endDate}")
@GET("/emotion/{startDate}/{endDate}")
suspend fun getDiaryStatistics(
@Header("Authorization") accessToken: String,
@Path("startDate") startDate: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ data class EmotionStatistics(
val angerCount: Int,
val anxietyCount: Int,
val depressionCount: Int,
val happiness: Int
val happinessCount: Int,
val boringCount: Int
)
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.nabi.nabi.views.diary.statistics

import android.app.DatePickerDialog
import android.widget.TextView
import androidx.fragment.app.viewModels
import com.nabi.domain.model.emotion.EmotionStatistics
import com.nabi.nabi.R
import com.nabi.nabi.base.BaseFragment
import com.nabi.nabi.databinding.FragmentStatisticsDiaryBinding
import com.nabi.nabi.utils.LoggerUtils
import com.nabi.nabi.utils.UiState
import dagger.hilt.android.AndroidEntryPoint
import java.text.SimpleDateFormat
Expand Down Expand Up @@ -110,12 +110,12 @@ class DiaryStatisticsFragment: BaseFragment<FragmentStatisticsDiaryBinding>(R.la

private fun setupChart(p: EmotionStatistics) {
binding.barChart.setValues(
p.run { intArrayOf(angerCount, happiness, 0, depressionCount, anxietyCount) }
p.run { intArrayOf(angerCount, happinessCount, boringCount, depressionCount, anxietyCount) }
)

binding.tvEmotionAngerValue.text = p.angerCount.toString()
binding.tvEmotionHappinessValue.text = p.happiness.toString()
binding.tvEmotionBoredomValue.text = "0"
binding.tvEmotionHappinessValue.text = p.happinessCount.toString()
binding.tvEmotionBoredomValue.text = p.boringCount.toString()
binding.tvEmotionSadnessValue.text = p.depressionCount.toString()
binding.tvEmotionAnxietyValue.text = p.anxietyCount.toString()
}
Expand All @@ -128,7 +128,7 @@ class DiaryStatisticsFragment: BaseFragment<FragmentStatisticsDiaryBinding>(R.la
is UiState.Loading -> {}
is UiState.Failure -> {
showToast("감정 톡계 λ‘œλ“œ μ‹€νŒ¨")
setupChart(EmotionStatistics(3, 6, 0, 4))
setupChart(EmotionStatistics(0, 0, 0, 0, 0))
}
is UiState.Success -> {
setupChart(it.data)
Expand Down

0 comments on commit 20806cf

Please sign in to comment.