-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from YAPP-Github/QA/75-oboard-vote-data
Qa/75 78 LoginScreen 실제 투표 데이터로 교체, 로고 위치 조정
- Loading branch information
Showing
13 changed files
with
141 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.susu.core.model | ||
|
||
import androidx.compose.runtime.Stable | ||
|
||
@Stable | ||
data class OnboardVote( | ||
val mostContent: String, | ||
val mostPercentage: Int, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
data/src/main/java/com/susu/data/data/repository/OnboardRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.susu.data.data.repository | ||
|
||
import com.susu.core.model.OnboardVote | ||
import com.susu.data.remote.api.OnboardService | ||
import com.susu.domain.repository.OnboardRepository | ||
import javax.inject.Inject | ||
|
||
class OnboardRepositoryImpl @Inject constructor( | ||
private val onboardService: OnboardService, | ||
) : OnboardRepository { | ||
override suspend fun getOnboardVote(): OnboardVote { | ||
val result = onboardService.getOnboardVote().getOrThrow().options | ||
val mostOption = result.maxBy { it.count } | ||
|
||
return OnboardVote( | ||
mostContent = mostOption.content, | ||
mostPercentage = (mostOption.count.toFloat() / result.sumOf { it.count } * 100).toInt(), | ||
) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
data/src/main/java/com/susu/data/remote/api/OnboardService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.susu.data.remote.api | ||
|
||
import com.susu.data.remote.model.response.OnboardVoteResponse | ||
import com.susu.data.remote.retrofit.ApiResult | ||
import retrofit2.http.GET | ||
|
||
interface OnboardService { | ||
@GET("votes/onboarding") | ||
suspend fun getOnboardVote(): ApiResult<OnboardVoteResponse> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
data/src/main/java/com/susu/data/remote/model/response/OnboardVoteResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.susu.data.remote.model.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class OnboardVoteResponse( | ||
val options: List<OnboardVoteOption>, | ||
) | ||
|
||
@Serializable | ||
data class OnboardVoteOption( | ||
val content: String = "", | ||
val count: Int = 0, | ||
) |
7 changes: 7 additions & 0 deletions
7
domain/src/main/java/com/susu/domain/repository/OnboardRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.susu.domain.repository | ||
|
||
import com.susu.core.model.OnboardVote | ||
|
||
interface OnboardRepository { | ||
suspend fun getOnboardVote(): OnboardVote | ||
} |
14 changes: 14 additions & 0 deletions
14
domain/src/main/java/com/susu/domain/usecase/loginsignup/GetOnboardVoteUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.susu.domain.usecase.loginsignup | ||
|
||
import com.susu.core.common.runCatchingIgnoreCancelled | ||
import com.susu.domain.repository.OnboardRepository | ||
import javax.inject.Inject | ||
|
||
class GetOnboardVoteUseCase @Inject constructor( | ||
private val onboardRepository: OnboardRepository, | ||
) { | ||
|
||
suspend operator fun invoke() = runCatchingIgnoreCancelled { | ||
onboardRepository.getOnboardVote() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters