Skip to content

Conversation

l5x5l
Copy link
Contributor

@l5x5l l5x5l commented Aug 9, 2025

[ PR Content ]

감정 구슬을 선택하면 나오는 추천 루틴을 등록하였을 때 해당 루틴이 홈 화면에 바로 반영되지 않는 문제를 수정합니다.

Related issue

Screenshot 📸

Screen_recording_20250809_185924.webm

Work Description

  • 홈 화면에서 추천 루틴을 등록했는지 여부를 감지하여 추천 루틴 등록 이벤트가 감지되었을 경우 현재 표시되는 주의 루틴을 다시 로드하도록 구현

To Reviewers 📢

  • 관련 UseCase, Repository메서드 로직들이 onBoarding 도메인에 구현되어 있는데, 이는 현재 추천 루틴을 등록하는 api주소가 api/v1/onboardings/routines 이기 때문에 api호출부의 통일성을 유지하기 위함입니다!
  • 추가적으로 궁금한 점 있으시면 코멘트 부탁드립니다!

Summary by CodeRabbit

  • New Features
    • 온보딩 추천 루틴 이벤트를 비동기적으로 스트림 형태로 받아볼 수 있는 기능이 추가되었습니다.
    • 추천 루틴 등록 시 이벤트가 발생하며, 이를 통해 홈 화면에서 주간 루틴이 자동으로 갱신됩니다.

@l5x5l l5x5l requested a review from wjdrjs00 August 9, 2025 10:15
@l5x5l l5x5l self-assigned this Aug 9, 2025
@l5x5l l5x5l added 🐞 Fix 버그 수정 세환 labels Aug 9, 2025
Copy link

coderabbitai bot commented Aug 9, 2025

Walkthrough

추천 루틴 추가 시점에 이벤트 플로우를 통해 홈 화면이 즉시 갱신되도록, 도메인 모델과 저장소, 유스케이스, 그리고 HomeViewModel에 관련 이벤트 스트림과 관찰 로직이 추가되었습니다. 새로운 이벤트 타입과 플로우가 도입되어 추천 루틴 추가가 홈에 실시간 반영됩니다.

Changes

Cohort / File(s) Change Summary
OnBoardingRecommendRoutineEvent 도메인 도입
domain/src/main/java/com/threegap/bitnagil/domain/onboarding/model/OnBoardingRecommendRoutineEvent.kt
새로운 sealed interface OnBoardingRecommendRoutineEventAddRoutines 이벤트 타입 추가
OnBoardingRepository 인터페이스 및 구현 확장
domain/src/main/java/com/threegap/bitnagil/domain/onboarding/repository/OnBoardingRepository.kt,
data/src/main/java/com/threegap/bitnagil/data/onboarding/repositoryImpl/OnBoardingRepositoryImpl.kt
추천 루틴 이벤트 플로우 관련 메서드 및 플로우 필드 추가, 루틴 등록 성공 시 이벤트 발행 로직 추가
추천 루틴 이벤트 플로우 유스케이스
domain/src/main/java/com/threegap/bitnagil/domain/onboarding/usecase/GetOnBoardingRecommendRoutineEventFlowUseCase.kt
이벤트 플로우를 반환하는 유스케이스 클래스 신설
HomeViewModel 이벤트 관찰 및 갱신
presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt
추천 루틴 이벤트 플로우를 관찰하여 홈 루틴을 즉시 갱신하는 로직 추가 및 관련 의존성 주입

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ViewModel
    participant UseCase
    participant Repository
    participant DataSource

    User->>ViewModel: 추천 루틴 추가 요청
    ViewModel->>Repository: registerRecommendRoutineList()
    Repository->>DataSource: registerRecommendRoutineList()
    DataSource-->>Repository: Result.Success
    Repository->>Repository: _onBoardingRecommendRoutineEventFlow.emit(AddRoutines)
    Repository-->>ViewModel: (이벤트 플로우 노출)
    ViewModel->>UseCase: getOnBoardingRecommendRoutineEventFlow()
    UseCase->>Repository: getOnBoardingRecommendRoutineEventFlow()
    Repository-->>UseCase: Flow<OnBoardingRecommendRoutineEvent>
    UseCase-->>ViewModel: Flow<OnBoardingRecommendRoutineEvent>
    ViewModel->>ViewModel: 이벤트 수신 시 fetchWeeklyRoutines()
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

Objective Addressed Explanation
감정 구슬 기반 추천 루틴 추가시 바로 홈 화면에 보여지도록 수정 (#86)

Assessment against linked issues: Out-of-scope changes

(해당 변경사항 중 범위 외 변경사항 없음)

Poem

추천 루틴 토끼가 깡총깡총
홈 화면에 루틴을 바로 띄워요
SharedFlow로 소식 전하면
ViewModel이 귀 쫑긋 반응하네
사용자 기쁨도 한가득,
오늘도 토끼는 코드에 춤추네! 🐰✨

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 96d5468 and 90c8cf3.

📒 Files selected for processing (1)
  • data/src/main/java/com/threegap/bitnagil/data/onboarding/repositoryImpl/OnBoardingRepositoryImpl.kt (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • data/src/main/java/com/threegap/bitnagil/data/onboarding/repositoryImpl/OnBoardingRepositoryImpl.kt
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/emotion_recommend_routine

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (4)
domain/src/main/java/com/threegap/bitnagil/domain/onboarding/repository/OnBoardingRepository.kt (1)

14-15: 이벤트 Flow 반환에는 suspend가 불필요합니다.

Flow 객체 획득은 비차단/즉시 연산이라 suspend가 오히려 호출 측 제약만 추가합니다. 기존 패턴(다른 이벤트 UseCase/Repo)과의 일관성을 위해 suspend 제거를 권장합니다.

적용 diff:

-    suspend fun getOnBoardingRecommendRoutineEventFlow(): Flow<OnBoardingRecommendRoutineEvent>
+    fun getOnBoardingRecommendRoutineEventFlow(): Flow<OnBoardingRecommendRoutineEvent>
domain/src/main/java/com/threegap/bitnagil/domain/onboarding/model/OnBoardingRecommendRoutineEvent.kt (1)

3-5: 이벤트 모델링 적절합니다.

sealed interface + AddRoutines 형태로 확장성 좋습니다. 향후 의미 명확화를 위해 KDoc 추가 정도만 고려해 주세요.

domain/src/main/java/com/threegap/bitnagil/domain/onboarding/usecase/GetOnBoardingRecommendRoutineEventFlowUseCase.kt (1)

11-14: UseCase의 invoke에 suspend 불필요 — 한 줄로 단순화 가능

Flow를 단순 위임 반환하므로 suspend 제거 시 호출/가독성 개선됩니다.

적용 diff:

-    suspend operator fun invoke(): Flow<OnBoardingRecommendRoutineEvent> {
-        return repository.getOnBoardingRecommendRoutineEventFlow()
-    }
+    operator fun invoke(): Flow<OnBoardingRecommendRoutineEvent> =
+        repository.getOnBoardingRecommendRoutineEventFlow()
presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt (1)

257-263: 이벤트 수집부 예외 처리와 타입 분기 추가 제안

  • collect에서 예외가 던져지면 코루틴이 취소되어 이후 이벤트를 놓칩니다. catch 연산자 추가를 권장합니다.
  • sealed 이벤트 확장을 대비해 타입 분기로 필요한 이벤트에만 갱신을 트리거하세요.

적용 diff:

-        viewModelScope.launch {
-            getOnBoardingRecommendRoutineEventFlowUseCase().collect {
-                fetchWeeklyRoutines(stateFlow.value.currentWeeks)
-            }
-        }
+        viewModelScope.launch {
+            getOnBoardingRecommendRoutineEventFlowUseCase()
+                .catch { e -> Log.e("HomeViewModel", "추천 루틴 이벤트 스트림 오류: ${e.message}", e) }
+                .collect { event ->
+                    when (event) {
+                        is com.threegap.bitnagil.domain.onboarding.model.OnBoardingRecommendRoutineEvent.AddRoutines -> {
+                            fetchWeeklyRoutines(stateFlow.value.currentWeeks)
+                        }
+                    }
+                }
+        }

추가 필요 import:

import kotlinx.coroutines.flow.catch
// (선호 시) import com.threegap.bitnagil.domain.onboarding.model.OnBoardingRecommendRoutineEvent
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4877f78 and 96d5468.

📒 Files selected for processing (5)
  • data/src/main/java/com/threegap/bitnagil/data/onboarding/repositoryImpl/OnBoardingRepositoryImpl.kt (2 hunks)
  • domain/src/main/java/com/threegap/bitnagil/domain/onboarding/model/OnBoardingRecommendRoutineEvent.kt (1 hunks)
  • domain/src/main/java/com/threegap/bitnagil/domain/onboarding/repository/OnBoardingRepository.kt (1 hunks)
  • domain/src/main/java/com/threegap/bitnagil/domain/onboarding/usecase/GetOnBoardingRecommendRoutineEventFlowUseCase.kt (1 hunks)
  • presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (1)
presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt (1)

8-8: 주입 및 구독 지점 추가는 의도에 부합

Home에서 온보딩 추천 루틴 이벤트를 관찰해 즉시 갱신하는 흐름이 적절합니다. 아래 수집부에 예외 처리만 보완하면 안정성이 올라갑니다(다음 코멘트 참고).

Also applies to: 51-51, 63-63

Copy link
Member

@wjdrjs00 wjdrjs00 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다! 깔쌈하네용!

@l5x5l l5x5l merged commit 5de90c6 into develop Aug 9, 2025
2 checks passed
@l5x5l l5x5l deleted the fix/emotion_recommend_routine branch August 9, 2025 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
세환 🐞 Fix 버그 수정
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FIX] 감정 구슬 기반 추천 루틴 추가 반영 문제 수정
2 participants