Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v1.3.0 #236

Merged
merged 112 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
db2e514
feat : PartyRunGradientRoundedRect Composable 추가 #PAR-357
nohjunh Sep 20, 2023
1c147a6
feat : MyPage StatusBar Mock Composable 추가 #PAR-357
nohjunh Sep 20, 2023
4cc0150
chore : 마이페이지에서 쓰일 싱글, 배틀 아이콘 추가 #PAR-357
nohjunh Sep 20, 2023
6fc424e
chore : 달린 기록이 존재하지 않을 때 보여줄 Lottile Raw json 추가 #PAR-357
nohjunh Sep 20, 2023
f304092
chore : MyPage Module strings.xml 업데이트 #PAR-357
nohjunh Sep 20, 2023
d132d98
feat : MyPage 결과 조회 Composable 적용 #PAR-357
nohjunh Oct 6, 2023
16766a6
Merge branch 'develop' into PAR-357
nohjunh Oct 6, 2023
9b5cba9
Merge pull request #221 from SWM-KAWAI-MANS/PAR-357
nohjunh Oct 6, 2023
9217f3d
refactor : signOut 함수 -> settings로 이동
nohjunh Oct 6, 2023
2d767b1
refactor : strings.xml 업데이트
nohjunh Oct 6, 2023
efeea62
refactor : 로그아웃 로직을 feature/settings에서 처리하도록 변경
nohjunh Oct 6, 2023
fda1727
Merge pull request #222 from SWM-KAWAI-MANS/refactor/sign_out
nohjunh Oct 6, 2023
797abc2
refactor : 메소드명 명확히 변경 #PAR-380
nohjunh Oct 9, 2023
a72cad6
feat : 마이페이지 종합기록 조회 data class 정의 #PAR-380
nohjunh Oct 9, 2023
7d681ed
feat : getComprehensiveRunRecord Network layer 구축 #PAR-380
nohjunh Oct 9, 2023
c9ae327
feat : 마이페이지 종합기록 조회 Repository, UseCase 구축 #PAR-380
nohjunh Oct 9, 2023
7d0202e
refactor : feature/match strings.xml Colon 제거
nohjunh Oct 9, 2023
f5e64f7
refactor : elapsed_time, time_remaining_acceptance Colon 간격 삽입
nohjunh Oct 9, 2023
05c4814
Merge pull request #223 from SWM-KAWAI-MANS/refactor/match_colon
nohjunh Oct 9, 2023
0248374
refactor : API 명세에 따른 타입 변경 #PAR-380
nohjunh Oct 10, 2023
7633af5
feat : 종합기록 확장함수 적용 #PAR-380
nohjunh Oct 10, 2023
e81c5c5
refactor : second 제외하고 시,분으로만 종합 달린 시간 표시 #PAR-380
nohjunh Oct 10, 2023
0ba350d
refactor : MyPage Component 분리 #PAR-380
nohjunh Oct 10, 2023
0a85b80
feat : ShimmerEffect Modifier 확장함수 추가 #PAR-380
nohjunh Oct 10, 2023
1435336
feat : MyPageUiState State API별 분리 #PAR-380
nohjunh Oct 10, 2023
2843acc
refactor : ProfileScreen myPageUiState -> myPageProfileState 변경 #PAR-380
nohjunh Oct 10, 2023
1d816b6
feat : 종합기록 조회 API 연동 #PAR-380
nohjunh Oct 10, 2023
8a299ed
Merge pull request #224 from SWM-KAWAI-MANS/PAR-380
nohjunh Oct 10, 2023
84a128f
feat : ResultRepository Single 기록 조회 추가 #PAR-381
nohjunh Oct 10, 2023
36f975c
feat : GetSingleHistoryUseCase 추가 #PAR-381
nohjunh Oct 10, 2023
b8ef1f9
feat : 싱글 기록 조회 data class 정의 #PAR-381
nohjunh Oct 10, 2023
f39bff5
feat : 싱글 기록 조회 ApiService 추가 #PAR-381
nohjunh Oct 10, 2023
1717e4c
feat : ResultDataSource 싱글 기록 조회 추가 #PAR-381
nohjunh Oct 10, 2023
e75de97
feat : ShimmerEffect 블랙테마 분기 추가 #PAR-381
nohjunh Oct 10, 2023
8840dd7
refactor : ShimmerEffect 코드 리팩토링 #PAR-381
nohjunh Oct 10, 2023
1cd0c38
refactor : RunningHistory Composable을 빼고 기존 mockData를 RunningHistoryD…
nohjunh Oct 10, 2023
0a06bd6
feat : ShimmerRunningHistory 컴포저블 추가 #PAR-381
nohjunh Oct 10, 2023
32dbd1d
feat : StatusElement 파라미터 theme 적용 #PAR-381
nohjunh Oct 10, 2023
f1dcb45
feat : RunningHistoryState 추가 및 SingleHistory 처리 #PAR-381
nohjunh Oct 10, 2023
a33663d
feat : 싱글 기록 조회 API MyPageViewModel 연동 #PAR-381
nohjunh Oct 10, 2023
d9662cb
feat : MyPageScreen 싱글 기록 조회 결과 반영 #PAR-381
nohjunh Oct 10, 2023
bab2ad8
refactor : 의도를 명확하게 하기 위한 컴포저블 네이밍 변경 #PAR-381
nohjunh Oct 10, 2023
dfb326d
refactor : 테스트를 위해 넣은 delay 제거 #PAR-381
nohjunh Oct 10, 2023
c7fd9be
feat : MyPage에서 SingleResult Navigation 추가 #PAR-381
nohjunh Oct 11, 2023
1a48b35
feat : MyPage에서 기록 조회 수행 시 ModeType 분기를 위한 enum 정의 #PAR-381
nohjunh Oct 11, 2023
268a522
feat : MyPage에서 싱글 기록 조회 수행 #PAR-381
nohjunh Oct 11, 2023
99c909a
refactor : Rename this parameter to match the regular expression #PAR…
nohjunh Oct 11, 2023
f8320d5
refactor : 임시 Battle block of code #PAR-381
nohjunh Oct 11, 2023
1c2386b
refactor : Rename this parameter to match the regular expression #PAR…
nohjunh Oct 11, 2023
a41725c
Merge pull request #225 from SWM-KAWAI-MANS/PAR-381
nohjunh Oct 11, 2023
c3d5905
feat : MyPage로부터 전환이 이루어진 것인지 확인하기 위한 NavArg 처리
nohjunh Oct 11, 2023
d393df8
feat : MyPage로부터 결과로 전환인지에 따라 navigation 다르게 처리
nohjunh Oct 11, 2023
4e857e2
Merge pull request #226 from SWM-KAWAI-MANS/feat/result_branching
nohjunh Oct 11, 2023
cde7f60
refactor : 싱글과 대결모드의 결과조회 API명세를 동일하게 가져가게 바꿈으로써 RunningHistoryDetail…
nohjunh Oct 11, 2023
c2b92a4
feat : 대결 기록 조회 data class 정의 #PAR-382
nohjunh Oct 11, 2023
042d822
feat : 대결 기록 조회 ApiService 추가 #PAR-382
nohjunh Oct 11, 2023
df12857
feat : ResultDataSource 대결 기록 조회 추가 #PAR-382
nohjunh Oct 11, 2023
9f1dc40
feat : ResultRepository 대결 기록 조회 추가 #PAR-382
nohjunh Oct 11, 2023
c1ac499
feat : CombinedRunningHistory data class 정의 #PAR-382
nohjunh Oct 11, 2023
1ada781
feat : MyPage에서 BattleResult Navigation 추가 #PAR-382
nohjunh Oct 11, 2023
2991166
feat : 싱글, 대결 기록을 Combine하여 한 번에 통합 처리 #PAR-382
nohjunh Oct 11, 2023
dc9a48a
feat : 대결모드 러닝 기록 조회 결과 Screen 반영 #PAR-382
nohjunh Oct 11, 2023
f57e2f3
feat : 대결모드 결과 스크린에도 navigateToBack() 전달 #PAR-382
nohjunh Oct 11, 2023
ed805fa
feat : MyPageViewModel getRunningHistory() Loading State 처리 #PAR-382
nohjunh Oct 11, 2023
34a2dd1
Merge pull request #227 from SWM-KAWAI-MANS/PAR-382
nohjunh Oct 12, 2023
9fb019c
refactor : ui -> component로 디렉터리명 수정
nohjunh Oct 13, 2023
9cb9cf6
refactor : getMyPageUserData를 LaunchedEffect로 처리
nohjunh Oct 13, 2023
a83793b
refactor : ProfileBackNavigationHandler 제거
nohjunh Oct 13, 2023
efe6564
Merge pull request #228 from SWM-KAWAI-MANS/refactor/profile
nohjunh Oct 13, 2023
077d5c4
feat : core:database Module 생성 #PAR-383
nohjunh Oct 14, 2023
b94fdf9
feat : build-logic AndroidRoomConventionPlugin 추가 #PAR-383
nohjunh Oct 14, 2023
77c6d0c
feat : build-logic AndroidRoomConventionPlugin 등록 #PAR-383
nohjunh Oct 14, 2023
cbef850
feat : 싱글, 대결 러닝 기록 조회 DAO 추가 #PAR-383
nohjunh Oct 14, 2023
d998c8a
feat : core:database DaosModule 생성 #PAR-383
nohjunh Oct 14, 2023
9662d56
feat : core:database DatabaseModule 생성 #PAR-383
nohjunh Oct 14, 2023
cccb298
feat : 싱글, 대결 러닝 기록 조회 Entity 정의 #PAR-383
nohjunh Oct 14, 2023
0f6686b
feat : core:database PartyRunDatabase 생성 #PAR-383
nohjunh Oct 14, 2023
8c85652
feat : core:network에 core:database dependency 추가 #PAR-383
nohjunh Oct 14, 2023
bc7b60d
feat : core:data에 core:database dependency 추가 #PAR-383
nohjunh Oct 14, 2023
0e7ff4d
feat : 싱글, 대결 러닝 기록 업데이트 UseCase 추가 #PAR-383
nohjunh Oct 14, 2023
048158e
feat : 싱글, 대결 러닝 기록 조회 Response에 toEntity 확장함수 추가 #PAR-383
nohjunh Oct 14, 2023
a5da463
feat : ResultRepository 싱글, 대결 기록 조회 Room DB에 업데이트 추가 #PAR-383
nohjunh Oct 14, 2023
dd3f69d
feat : 싱글, 대결 기록 조회 GET 방식 remote -> database로 변경 #PAR-383
nohjunh Oct 14, 2023
7494d95
feat : MainNavHost popUpTo 일부 변경 #PAR-383
nohjunh Oct 14, 2023
b34bead
feat : 싱글, 대결 러닝 기록 DB에 업데이트 로직 추가 #PAR-383
nohjunh Oct 14, 2023
db6cc2b
feat : 러닝이 끝난 후의 기록 조회 상황에서만 기록 최신화 업데이트 수행 #PAR-383
nohjunh Oct 14, 2023
446a593
feat : 싱글, 대결 기록 DELETE 쿼리 추가 #PAR-383
nohjunh Oct 14, 2023
9e2b35f
feat : ResultRepository deleteAllHistories 추가 #PAR-383
nohjunh Oct 14, 2023
0a41bf2
feat : DeleteRunningHistoryUseCase 추가 #PAR-383
nohjunh Oct 14, 2023
34e65f1
refactor : UnsubscribeScreen Toast 코드 단순화 #PAR-383
nohjunh Oct 14, 2023
4a7e218
feat : 로그아웃, 회원탈퇴 시 러닝 기록 Room DB 초기화 #PAR-383
nohjunh Oct 14, 2023
5219261
refactor : RunningHistoryDetailResponse 중복 코드 함수 분리 #PAR-383
nohjunh Oct 14, 2023
539ed46
refactor : Define a constant instead of duplicating this literal #PAR…
nohjunh Oct 14, 2023
f0ac86c
Merge pull request #229 from SWM-KAWAI-MANS/PAR-383
nohjunh Oct 14, 2023
1850def
fix : GoogleMap isMyLocationEnabled property Exception 처리 #PAR-384
nohjunh Oct 14, 2023
49119e6
Merge pull request #230 from SWM-KAWAI-MANS/PAR-384
nohjunh Oct 14, 2023
8a90a69
feat : calculatePaceInMinPerKm() 추가 및 적용
nohjunh Oct 14, 2023
a191aea
Merge pull request #231 from SWM-KAWAI-MANS/feat/calculatePaceInMinPerKm
nohjunh Oct 14, 2023
1cb9eef
refactor : 불필요한 matchApiService 제거
nohjunh Oct 15, 2023
1c3ce9e
refactor : MatchApiService로 통합
nohjunh Oct 15, 2023
f1bc16a
Merge pull request #232 from SWM-KAWAI-MANS/refactor/match_service
nohjunh Oct 15, 2023
8d9ff9a
chore : feature/running_result strings.xml 업데이트, lottie 추가
nohjunh Oct 16, 2023
ad0b4d8
fix : 대결에 참여한 러너 중 빈 기록이 있는 경우 별도 처리
nohjunh Oct 16, 2023
d1f3fb8
Merge pull request #233 from SWM-KAWAI-MANS/fix/empty_records
nohjunh Oct 17, 2023
f91319c
refactor : core:common import * 제거 및 명시적 선언
nohjunh Oct 19, 2023
765a327
refactor : core:data 컨벤션에 정의된 중복 Hilt 의존성 제거
nohjunh Oct 19, 2023
0a1090f
refactor : SnackbarBox strings.xml로 문자열 처리
nohjunh Oct 19, 2023
41f7577
refactor : App Module import * 수정 및 컨벤션 적용 후 중복 선언 제거
nohjunh Oct 19, 2023
1375403
Merge pull request #234 from SWM-KAWAI-MANS/refactor/detail
nohjunh Oct 19, 2023
8fd70f3
refactor : 컨벤션 플러그인에 정의된 불필요한 kotlinCompilerExtensionVersion Configur…
nohjunh Oct 19, 2023
4bc5fcc
Merge pull request #235 from SWM-KAWAI-MANS/refactor/detail
nohjunh Oct 19, 2023
ee71b64
chore : 버전코드 변경 (v1.3.0)
nohjunh Oct 19, 2023
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
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 2 additions & 13 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import java.io.File
import java.io.FileInputStream
import java.util.*
import java.util.Properties

plugins {
id("nohjunh.android.application")
id("nohjunh.android.application.compose")
id("nohjunh.android.hilt")
id("com.google.gms.google-services")
id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
id("nohjunh.android.hilt")
}

val keystoreProperties = Properties()
Expand Down Expand Up @@ -79,21 +79,10 @@ android {
)
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
buildFeatures {
compose = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = Configurations.COMPOSE
}
kapt {
correctErrorTypes = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ fun SetUpMainNavGraph(
)

myPageRoute(
onSignOut = onSignOut,
navigateToSettings = {
navController.navigate(MainNavRoutes.Settings.route)
},
Expand All @@ -110,6 +109,20 @@ fun SetUpMainNavGraph(
navigateToProfile = {
navController.navigate(MainNavRoutes.Profile.route)
},
navigateToSingleResult = { isFromMyPage ->
navController.navigate("${MainNavRoutes.SingleResult.route}?isFromMyPage=$isFromMyPage") {
popUpTo(MainNavRoutes.MyPage.route) {
inclusive = false
}
}
},
navigateToBattleResult = { isFromMyPage ->
navController.navigate("${MainNavRoutes.BattleResult.route}?isFromMyPage=$isFromMyPage") {
popUpTo(MainNavRoutes.MyPage.route) {
inclusive = false
}
}
},
onShowSnackbar = onShowSnackbar
)

Expand All @@ -124,7 +137,7 @@ fun SetUpMainNavGraph(
navigateToBattleResult = {
navController.navigate(MainNavRoutes.BattleResult.route) {
popUpTo(MainNavRoutes.Battle.route) {
inclusive = false
inclusive = true
}
}
},
Expand All @@ -135,7 +148,7 @@ fun SetUpMainNavGraph(
navigateToSingleResult = {
navController.navigate(MainNavRoutes.SingleResult.route) {
popUpTo(MainNavRoutes.Single.route) {
inclusive = false
inclusive = true
}
}
},
Expand All @@ -145,10 +158,13 @@ fun SetUpMainNavGraph(
runningResultRoute(
navigateToTopLevel = {
navController.navigate(MainNavRoutes.Battle.route) {
popUpTo(MainNavRoutes.Battle.route) {
popUpTo(navController.graph.findStartDestination().id) {
inclusive = true
}
}
},
navigateToBack = {
navController.popBackStack()
}
)

Expand Down
4 changes: 4 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ gradlePlugin {
id = "nohjunh.android.library"
implementationClass = "AndroidLibraryConventionPlugin"
}
register("androidRoom") {
id = "nohjunh.android.room"
implementationClass = "AndroidRoomConventionPlugin"
}
register("androidFeature") {
id = "nohjunh.android.feature"
implementationClass = "AndroidFeatureConventionPlugin"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import com.google.devtools.ksp.gradle.KspExtension
import online.partyrun.partyrunapplication.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies

class AndroidRoomConventionPlugin : Plugin<Project> {

override fun apply(target: Project) {
with(target) {
pluginManager.apply("com.google.devtools.ksp")

extensions.configure<KspExtension> {
}

dependencies {
add("implementation", libs.findLibrary("room.runtime").get())
add("implementation", libs.findLibrary("room.ktx").get())
add("ksp", libs.findLibrary("room.compiler").get())
}
}
}
}
6 changes: 2 additions & 4 deletions buildSrc/src/main/java/Configurations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ object Configurations {
const val MIN_SDK_VERSION = 26
const val TARGET_SDK_VERSION = 33
private const val MAJOR_VERSION = 1
private const val MINOR_VERSION = 2
private const val MINOR_VERSION = 3
private const val PATCH_VERSION = 0
const val VERSION_NAME = "$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION"
const val VERSION_CODE = 22
// kotlinCompilerExtensionVersion
const val COMPOSE = "1.4.5"
const val VERSION_CODE = 23
}
2 changes: 1 addition & 1 deletion core/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java.io.File
import java.io.FileInputStream
import java.util.*
import java.util.Properties

plugins {
id("nohjunh.android.library")
Expand Down
5 changes: 1 addition & 4 deletions core/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ dependencies {
implementation(project(":core:datastore"))
implementation(project(":core:model"))
implementation(project(":core:network"))
implementation(project(":core:database"))

implementation(libs.androidx.core.ktx)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.kotlinx.serialization.json)

implementation(libs.hilt.android)
implementation(libs.androidx.hilt.navigation.compose)
kapt(libs.hilt.compiler)

implementation(libs.google.location)

testImplementation(project(":core:testing"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@ package online.partyrun.partyrunapplication.core.data.repository
import kotlinx.coroutines.flow.Flow
import online.partyrun.partyrunapplication.core.model.running_result.battle.BattleResult
import online.partyrun.partyrunapplication.core.common.result.Result
import online.partyrun.partyrunapplication.core.model.my_page.BattleRunningHistory
import online.partyrun.partyrunapplication.core.model.my_page.ComprehensiveRunRecord
import online.partyrun.partyrunapplication.core.model.my_page.SingleRunningHistory
import online.partyrun.partyrunapplication.core.model.running_result.single.SingleResult

interface ResultRepository {
suspend fun getBattleResults(): Flow<Result<BattleResult>>
suspend fun getSingleResults(): Flow<Result<SingleResult>>
suspend fun getComprehensiveRunRecord(): Flow<Result<ComprehensiveRunRecord>>
suspend fun updateSingleHistory(): Flow<Result<Unit>>
suspend fun updateBattleHistory(): Flow<Result<Unit>>
suspend fun getSingleHistory(): Flow<Result<SingleRunningHistory>>
suspend fun getBattleHistory(): Flow<Result<BattleRunningHistory>>
suspend fun deleteAllHistories(): Flow<Result<Unit>>

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,38 @@ package online.partyrun.partyrunapplication.core.data.repository

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import online.partyrun.partyrunapplication.core.common.network.apiRequestFlow
import online.partyrun.partyrunapplication.core.common.network.onException
import online.partyrun.partyrunapplication.core.common.network.onSuccess
import online.partyrun.partyrunapplication.core.datastore.datasource.BattlePreferencesDataSource
import online.partyrun.partyrunapplication.core.model.running_result.battle.BattleResult
import online.partyrun.partyrunapplication.core.network.datasource.ResultDataSource
import online.partyrun.partyrunapplication.core.network.model.response.toDomainModel
import online.partyrun.partyrunapplication.core.common.result.Result
import online.partyrun.partyrunapplication.core.common.result.mapResultModel
import online.partyrun.partyrunapplication.core.database.dao.BattleRunningHistoryDao
import online.partyrun.partyrunapplication.core.database.dao.SingleRunningHistoryDao
import online.partyrun.partyrunapplication.core.database.model.toDomainModel
import online.partyrun.partyrunapplication.core.datastore.datasource.SinglePreferencesDataSource
import online.partyrun.partyrunapplication.core.model.my_page.BattleRunningHistory
import online.partyrun.partyrunapplication.core.model.my_page.ComprehensiveRunRecord
import online.partyrun.partyrunapplication.core.model.my_page.SingleRunningHistory
import online.partyrun.partyrunapplication.core.model.running_result.single.SingleResult
import online.partyrun.partyrunapplication.core.network.model.response.toEntity
import javax.inject.Inject

class ResultRepositoryImpl @Inject constructor(
private val resultDataSource: ResultDataSource,
private val singleRunningHistoryDao: SingleRunningHistoryDao,
private val battleRunningHistoryDao: BattleRunningHistoryDao,
private val battlePreferencesDataSource: BattlePreferencesDataSource,
private val singlePreferencesDataSource: SinglePreferencesDataSource
) : ResultRepository {
companion object {
const val UNKNOWN_ERROR = "Unknown Error"
}

override suspend fun getBattleResults(): Flow<Result<BattleResult>> {
return apiRequestFlow {
Expand All @@ -33,4 +49,65 @@ class ResultRepositoryImpl @Inject constructor(
}.mapResultModel { it.toDomainModel() }
}

override suspend fun getComprehensiveRunRecord(): Flow<Result<ComprehensiveRunRecord>> {
return apiRequestFlow {
resultDataSource.getComprehensiveRunRecord()
}.mapResultModel { it.toDomainModel() }
}

override suspend fun updateSingleHistory(): Flow<Result<Unit>> = flow {
emit(Result.Loading)
val response = resultDataSource.getSingleHistory()
response.onSuccess { result ->
singleRunningHistoryDao.insertAllSingleRunningHistory(result.toEntity())
emit(Result.Success(Unit))
}.onException { e ->
emit(Result.Failure(e.message ?: UNKNOWN_ERROR, -1))
}
}

override suspend fun updateBattleHistory(): Flow<Result<Unit>> = flow {
emit(Result.Loading)
val response = resultDataSource.getBattleHistory()
response.onSuccess { result ->
battleRunningHistoryDao.insertAllBattleRunningHistory(result.toEntity())
emit(Result.Success(Unit))
}.onException { e ->
emit(Result.Failure(e.message ?: UNKNOWN_ERROR, -1))
}
}

override suspend fun getSingleHistory(): Flow<Result<SingleRunningHistory>> {
return singleRunningHistoryDao.getAllSingleRunningHistories()
.map { entityList ->
try {
Result.Success(SingleRunningHistory(entityList.map { it.toDomainModel() }))
} catch (e: Exception) {
Result.Failure(e.message ?: UNKNOWN_ERROR, -1)
}
}
}

override suspend fun getBattleHistory(): Flow<Result<BattleRunningHistory>> {
return battleRunningHistoryDao.getAllBattleRunningHistories()
.map { entityList ->
try {
Result.Success(BattleRunningHistory(entityList.map { it.toDomainModel() }))
} catch (e: Exception) {
Result.Failure(e.message ?: UNKNOWN_ERROR, -1)
}
}
}

override suspend fun deleteAllHistories(): Flow<Result<Unit>> = flow {
emit(Result.Loading)
try {
singleRunningHistoryDao.deleteAllSingleRunningHistories()
battleRunningHistoryDao.deleteAllBattleRunningHistories()
emit(Result.Success(Unit))
} catch (e: Exception) {
emit(Result.Failure(e.message ?: UNKNOWN_ERROR, -1))
}
}

}
1 change: 1 addition & 0 deletions core/database/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
18 changes: 18 additions & 0 deletions core/database/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plugins {
id("nohjunh.android.library")
id("nohjunh.android.hilt")
id("nohjunh.android.room")
}

android {
namespace = "online.partyrun.partyrunapplication.core.database"
}

dependencies {
implementation(project(":core:model"))

implementation(libs.kotlinx.coroutines.android)
implementation(libs.kotlinx.datetime)

androidTestImplementation(project(":core:testing"))
}
4 changes: 4 additions & 0 deletions core/database/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package online.partyrun.partyrunapplication.core.database

import androidx.room.Database
import androidx.room.RoomDatabase
import online.partyrun.partyrunapplication.core.database.dao.BattleRunningHistoryDao
import online.partyrun.partyrunapplication.core.database.dao.SingleRunningHistoryDao
import online.partyrun.partyrunapplication.core.database.model.BattleRunningHistoryEntity
import online.partyrun.partyrunapplication.core.database.model.SingleRunningHistoryEntity

@Database(
entities = [SingleRunningHistoryEntity::class, BattleRunningHistoryEntity::class],
version = 1
)
abstract class PartyRunDatabase : RoomDatabase() {

abstract fun singleRunningHistoryDao(): SingleRunningHistoryDao

abstract fun battleRunningHistoryDao(): BattleRunningHistoryDao
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package online.partyrun.partyrunapplication.core.database.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import kotlinx.coroutines.flow.Flow
import online.partyrun.partyrunapplication.core.database.model.BattleRunningHistoryEntity

@Dao
interface BattleRunningHistoryDao {

@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertAllBattleRunningHistory(historyEntities: List<BattleRunningHistoryEntity>)

@Query("SELECT * FROM battle_running_history_resource")
fun getAllBattleRunningHistories(): Flow<List<BattleRunningHistoryEntity>>

@Query("DELETE FROM battle_running_history_resource")
suspend fun deleteAllBattleRunningHistories()

}
Loading