[Refactor/#190] WriteRoutine 관련 도메인 및 데이터 레이어를 Routine으로 통합합니다.#191
[Refactor/#190] WriteRoutine 관련 도메인 및 데이터 레이어를 Routine으로 통합합니다.#191
Conversation
Walkthrough이 PR은 Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (4)
data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineEditRequest.kt (1)
29-40: 등록/수정 매핑 로직 공통화를 권장합니다.Line 29-40 매핑 패턴이 등록 요청 매퍼와 거의 동일해 추후 포맷/필드 변경 시 드리프트가 발생하기 쉽습니다. 공통 변환 유틸(특히 날짜/시간 포맷)을 분리해 두면 유지보수가 쉬워집니다.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineEditRequest.kt` around lines 29 - 40, The RoutineEditInfo.toDto mapping duplicates the registration mapper; extract shared mapping logic (especially date/time formatting) into a common utility or mapper function and use it from RoutineEditInfo.toDto and the registration mapper to avoid drift—e.g., centralize conversion of startDate/endDate/startTime to string and common field mappings used to build RoutineEditRequest so both the RoutineEditInfo.toDto function and the corresponding registration mapper call that shared routine-to-request converter.domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineEditInfo.kt (1)
6-15: 등록 모델과 동일한 불변식 검증을 맞춰 주세요.Line 6-15도
id/name공백, 날짜 역전 상태를 허용합니다.RoutineRegisterInfo와 동일한 기준으로init검증을 두면 일관성이 좋아집니다.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineEditInfo.kt` around lines 6 - 15, RoutineEditInfo currently allows blank id/name and inverted dates; add the same invariant checks used in RoutineRegisterInfo by adding an init block in RoutineEditInfo that validates non-blank id and name and enforces startDate <= endDate (and any other checks present in RoutineRegisterInfo such as non-empty repeatDay or valid startTime bounds if applicable). Implement the checks using require(...) (or equivalent) with clear messages so the invariants match RoutineRegisterInfo exactly and maintain consistency across the models.presentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinewrite/model/Day.kt (1)
15-15: 메서드명과 반환 타입 의미를 맞춰 주세요.Line 15의
toRepeatDay()는 이제DayOfWeek를 반환하므로,toDayOfWeek()처럼 이름을 맞추면 호출부 혼동을 줄일 수 있습니다.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@presentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinewrite/model/Day.kt` at line 15, The method toRepeatDay() in Day.kt returns a DayOfWeek but its name is misleading; rename the function to toDayOfWeek() (signature returning DayOfWeek) and update all callers to use the new name; if you need a non-breaking change, add a deprecated wrapper fun toRepeatDay() = toDayOfWeek() with `@Deprecated` annotation forwarding to the new toDayOfWeek() to give callers time to migrate.domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineRegisterInfo.kt (1)
7-15: 도메인 불변식 검증을 추가하는 것을 권장합니다.Line 7-15는 외부 입력을 그대로 담아
name공백,startDate > endDate같은 비정상 상태를 허용합니다.init { require(...) }로 최소 검증을 두면 하위 레이어 오류를 줄일 수 있습니다.예시 수정안
data class RoutineRegisterInfo( val name: String, val repeatDay: List<DayOfWeek>, val startTime: LocalTime, val startDate: LocalDate, val endDate: LocalDate, val subRoutines: List<String>, val recommendedRoutineType: RecommendCategory?, -) +) { + init { + require(name.isNotBlank()) { "name must not be blank" } + require(!startDate.isAfter(endDate)) { "startDate must be on or before endDate" } + } +}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineRegisterInfo.kt` around lines 7 - 15, RoutineRegisterInfo currently accepts invalid input (blank name, empty repeatDay, startDate after endDate, etc.); add an init { require(...) } block inside the RoutineRegisterInfo data class to validate fields: require(name.isNotBlank()), require(repeatDay.isNotEmpty()), require(!startDate.isAfter(endDate)), and any other invariants you want (e.g., subRoutines non-null/unique) referencing the properties name, repeatDay, startTime, startDate, endDate, and subRoutines so invalid instances are rejected at construction time.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineRegisterRequest.kt`:
- Line 33: The request uses LocalDate.toString() and LocalTime.toString() which
yield variable formats; fix the serialization in RoutineRegisterRequest.kt
(fields routineStartDate, routineEndDate, executionTime) and the toDto() in
RoutineEditRequest.kt by formatting dates/times with
DateTimeFormatter.ofPattern(...) (e.g., ISO_LOCAL_DATE and ISO_LOCAL_TIME or
your server-expected pattern) and pass the formatted strings instead of raw
toString() values; update the methods that set executionTime, routineStartDate,
and routineEndDate (and the toDto() implementation) to call format(formatter) so
the server receives a stable, explicit format.
In
`@data/src/main/java/com/threegap/bitnagil/data/routine/repositoryImpl/RoutineRepositoryImpl.kt`:
- Around line 55-56: The MutableSharedFlow _writeRoutineEventFlow currently uses
the default replay=0 which can drop events emitted before the ViewModel starts
collecting (registerRoutine()/editRoutine() emit synchronously while
observeRoutineChanges()/observeWriteRoutineEvent() start collection
asynchronously via viewModelScope.launch). Initialize _writeRoutineEventFlow
with a non-zero replay (e.g., MutableSharedFlow<WriteRoutineEvent>(replay = 1))
so the last emitted event is retained for late subscribers; update the
declaration of _writeRoutineEventFlow and keep getWriteRoutineEventFlow()
returning _writeRoutineEventFlow.asSharedFlow().
In
`@domain/src/main/java/com/threegap/bitnagil/domain/routine/repository/RoutineRepository.kt`:
- Line 19: The current WriteRoutine event flow can drop emits before subscribers
attach; update the implementation so late subscribers receive the last success
event by using a replaying SharedFlow instead of the default
MutableSharedFlow(). In RoutineRepositoryImpl, change the backing flow (the
MutableSharedFlow used for getWriteRoutineEventFlow) to include replay = 1
(e.g., MutableSharedFlow<WriteRoutineEvent>(replay = 1)) so the most recent
success event is retained for new subscribers; keep existing emit calls
(emit/tryEmit) as-is so producers still publish to the same flow.
---
Nitpick comments:
In
`@data/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineEditRequest.kt`:
- Around line 29-40: The RoutineEditInfo.toDto mapping duplicates the
registration mapper; extract shared mapping logic (especially date/time
formatting) into a common utility or mapper function and use it from
RoutineEditInfo.toDto and the registration mapper to avoid drift—e.g.,
centralize conversion of startDate/endDate/startTime to string and common field
mappings used to build RoutineEditRequest so both the RoutineEditInfo.toDto
function and the corresponding registration mapper call that shared
routine-to-request converter.
In
`@domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineEditInfo.kt`:
- Around line 6-15: RoutineEditInfo currently allows blank id/name and inverted
dates; add the same invariant checks used in RoutineRegisterInfo by adding an
init block in RoutineEditInfo that validates non-blank id and name and enforces
startDate <= endDate (and any other checks present in RoutineRegisterInfo such
as non-empty repeatDay or valid startTime bounds if applicable). Implement the
checks using require(...) (or equivalent) with clear messages so the invariants
match RoutineRegisterInfo exactly and maintain consistency across the models.
In
`@domain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineRegisterInfo.kt`:
- Around line 7-15: RoutineRegisterInfo currently accepts invalid input (blank
name, empty repeatDay, startDate after endDate, etc.); add an init {
require(...) } block inside the RoutineRegisterInfo data class to validate
fields: require(name.isNotBlank()), require(repeatDay.isNotEmpty()),
require(!startDate.isAfter(endDate)), and any other invariants you want (e.g.,
subRoutines non-null/unique) referencing the properties name, repeatDay,
startTime, startDate, endDate, and subRoutines so invalid instances are rejected
at construction time.
In
`@presentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinewrite/model/Day.kt`:
- Line 15: The method toRepeatDay() in Day.kt returns a DayOfWeek but its name
is misleading; rename the function to toDayOfWeek() (signature returning
DayOfWeek) and update all callers to use the new name; if you need a
non-breaking change, add a deprecated wrapper fun toRepeatDay() = toDayOfWeek()
with `@Deprecated` annotation forwarding to the new toDayOfWeek() to give callers
time to migrate.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2a748ea8-8a92-4db8-abf0-5d4fb16fa5c4
📒 Files selected for processing (34)
app/src/main/java/com/threegap/bitnagil/di/data/DataSourceModule.ktapp/src/main/java/com/threegap/bitnagil/di/data/RepositoryModule.ktapp/src/main/java/com/threegap/bitnagil/di/data/ServiceModule.ktdata/src/main/java/com/threegap/bitnagil/data/routine/datasource/RoutineRemoteDataSource.ktdata/src/main/java/com/threegap/bitnagil/data/routine/datasourceImpl/RoutineRemoteDataSourceImpl.ktdata/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineEditRequest.ktdata/src/main/java/com/threegap/bitnagil/data/routine/model/request/RoutineRegisterRequest.ktdata/src/main/java/com/threegap/bitnagil/data/routine/repositoryImpl/RoutineRepositoryImpl.ktdata/src/main/java/com/threegap/bitnagil/data/routine/service/RoutineService.ktdata/src/main/java/com/threegap/bitnagil/data/writeroutine/datasource/WriteRoutineDataSource.ktdata/src/main/java/com/threegap/bitnagil/data/writeroutine/datasourceImpl/WriteRoutineDataSourceImpl.ktdata/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/EditRoutineRequest.ktdata/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/RegisterRoutineRequest.ktdata/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.ktdata/src/main/java/com/threegap/bitnagil/data/writeroutine/service/WriteRoutineService.ktdomain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineEditInfo.ktdomain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineRegisterInfo.ktdomain/src/main/java/com/threegap/bitnagil/domain/routine/model/RoutineUpdateType.ktdomain/src/main/java/com/threegap/bitnagil/domain/routine/model/SubRoutineDeletionInfo.ktdomain/src/main/java/com/threegap/bitnagil/domain/routine/model/WriteRoutineEvent.ktdomain/src/main/java/com/threegap/bitnagil/domain/routine/repository/RoutineRepository.ktdomain/src/main/java/com/threegap/bitnagil/domain/routine/usecase/EditRoutineUseCase.ktdomain/src/main/java/com/threegap/bitnagil/domain/routine/usecase/GetWriteRoutineEventFlowUseCase.ktdomain/src/main/java/com/threegap/bitnagil/domain/routine/usecase/RegisterRoutineUseCase.ktdomain/src/main/java/com/threegap/bitnagil/domain/writeroutine/model/RepeatDay.ktdomain/src/main/java/com/threegap/bitnagil/domain/writeroutine/repository/WriteRoutineRepository.ktdomain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/EditRoutineUseCase.ktdomain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/GetWriteRoutineEventFlowUseCase.ktdomain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/RegisterRoutineUseCase.ktpresentation/src/main/java/com/threegap/bitnagil/presentation/screen/home/HomeViewModel.ktpresentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinelist/RoutineListViewModel.ktpresentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinewrite/RoutineWriteScreen.ktpresentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinewrite/RoutineWriteViewModel.ktpresentation/src/main/java/com/threegap/bitnagil/presentation/screen/routinewrite/model/Day.kt
💤 Files with no reviewable changes (15)
- app/src/main/java/com/threegap/bitnagil/di/data/DataSourceModule.kt
- data/src/main/java/com/threegap/bitnagil/data/writeroutine/datasourceImpl/WriteRoutineDataSourceImpl.kt
- data/src/main/java/com/threegap/bitnagil/data/writeroutine/repositoryImpl/WriteRoutineRepositoryImpl.kt
- domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/repository/WriteRoutineRepository.kt
- domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/GetWriteRoutineEventFlowUseCase.kt
- app/src/main/java/com/threegap/bitnagil/di/data/ServiceModule.kt
- app/src/main/java/com/threegap/bitnagil/di/data/RepositoryModule.kt
- data/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/EditRoutineRequest.kt
- data/src/main/java/com/threegap/bitnagil/data/writeroutine/datasource/WriteRoutineDataSource.kt
- domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/model/RepeatDay.kt
- data/src/main/java/com/threegap/bitnagil/data/writeroutine/service/WriteRoutineService.kt
- domain/src/main/java/com/threegap/bitnagil/domain/routine/model/SubRoutineDeletionInfo.kt
- data/src/main/java/com/threegap/bitnagil/data/writeroutine/model/request/RegisterRoutineRequest.kt
- domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/EditRoutineUseCase.kt
- domain/src/main/java/com/threegap/bitnagil/domain/writeroutine/usecase/RegisterRoutineUseCase.kt
[ PR Content ]
WriteRoutine 관련 도메인 및 데이터 레이어를 Routine으로 통합했습니다.
Related issue
Screenshot 📸
Work Description
RepeatDay를DayOfWeek로 대체하고 관련 모델(RoutineRegisterInfo,RoutineEditInfo등) 재정의To Reviewers 📢
Summary by CodeRabbit
릴리스 노트