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

[AN/USER] 축제 목록 캐싱 적용 (#591) #592

Closed
wants to merge 8 commits into from
Closed

[AN/USER] 축제 목록 캐싱 적용 (#591) #592

wants to merge 8 commits into from

Conversation

re4rk
Copy link
Collaborator

@re4rk re4rk commented Oct 24, 2023

📌 관련 이슈

✨ PR 세부 내용

  • Room을 적용했습니다.
  • loadFestivals()로 축제를 불러올 수 있으나 val festivals을 추가하여 값을 Flow형태로 받아올 수 있게도 변경했습니다. 해당 구조에 대해서 피드백을 원합니다.

@re4rk re4rk added AN 안드로이드에 관련된 작업 USER labels Oct 24, 2023
@re4rk re4rk self-assigned this Oct 24, 2023
@re4rk re4rk linked an issue Oct 24, 2023 that may be closed by this pull request
Copy link
Member

@SeongHoonC SeongHoonC left a comment

Choose a reason for hiding this comment

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

고생 많으셨습니다! 코멘트 확인해주세요!


interface FestivalRepository {
val festivals: Flow<List<Festival>>

suspend fun loadFestivals(): Result<List<Festival>>
Copy link
Member

Choose a reason for hiding this comment

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

실패 처리만 하고있어서 Result 만 반환해도 될 것 같네요

Comment on lines +34 to +43
_uiState.value = FestivalListUiState.Success(
festivals = it.map { festival ->
FestivalItemUiState(
id = festival.id,
name = festival.name,
startDate = festival.startDate,
endDate = festival.endDate,
thumbnail = festival.thumbnail,
onFestivalDetail = ::showTicketReserve,
)
Copy link
Member

Choose a reason for hiding this comment

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

개인적으로 private 함수로 분리했으면 좋겠습니당

Copy link
Member

@EmilyCh0 EmilyCh0 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다! 코멘트 남겼어용

Comment on lines +23 to +34
override val festivals: Flow<List<Festival>>
get() = festivalDao.getFestivals().transform { emit(it.toDomain()) }

override suspend fun loadFestivals(): Result<List<Festival>> =
runCatchingResponse { festivalRetrofitService.getFestivals() }
.onSuccessOrCatch { it.toDomain() }
.onSuccessOrCatch { festivals ->
festivals.toDomain().also {
CoroutineScope(Dispatchers.IO).launch {
festivalDao.replaceFestivals(it.toEntity())
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

서버에 새 데이터를 요청해서 불러오는 동안에 캐싱해둔 데이터를 보여줄 수 있고 좋네요 👍
(몰라서 하는 질문) 매번 내장 DB 테이블 전체를 Delete하고 Insert 하는 건 성능상 문제가 없나요??

Comment on lines +52 to +58
festivalRepository.loadFestivals().onFailure {
_uiState.value = FestivalListUiState.Error
analyticsHelper.logNetworkFailure(
KEY_LOAD_FESTIVALS_LOG,
it.message.toString(),
)
}
Copy link
Member

Choose a reason for hiding this comment

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

Room 써서 캐싱까지 할거면 Error 상태일 때도 캐싱된 데이터를 보여주면 좋을 것 같은데 이 부분 상태나 이벤트 처리 어떻게 할지 얘기 해봐야할 것 같아요!

@SeongHoonC SeongHoonC closed this Dec 11, 2023
@SeongHoonC SeongHoonC deleted the feat/#591 branch December 11, 2023 05:28
@SeongHoonC SeongHoonC restored the feat/#591 branch December 11, 2023 05:35
@SeongHoonC
Copy link
Member

불필요 브랜치를 삭제하다가 삭제해버렸네요. 죄송합니다!

@SeongHoonC SeongHoonC reopened this Dec 11, 2023
@re4rk re4rk closed this Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AN 안드로이드에 관련된 작업 USER
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[AN] 유저앱의 축제 목록에 캐싱 기능을 적용한다.
3 participants