-
Notifications
You must be signed in to change notification settings - Fork 1
feat: 내 서재에 기록 수 컬럼 추가 #74
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
Conversation
📝 WalkthroughWalkthroughUserBook 및 ReadingRecord 관련 도메인, DTO, 엔티티에 기록(레코드) 수 및 저자(author) 필드가 추가되었습니다. 이에 따라 관련 팩토리 메서드, 서비스, 엔티티, VO, DTO가 확장 및 수정되었으며, 일부 예외 처리 및 내부 로직이 보강되었습니다. 기타 코드 포맷팅 변경도 포함됩니다. Changes
Sequence Diagram(s)sequenceDiagram
participant API
participant UserBookDomainService
participant UserBookRepository
participant UserBookEntity
API->>UserBookDomainService: upsertUserBook(), findUserBooksByDynamicCondition(), ...
UserBookDomainService->>UserBookRepository: findById(), save(), 등
UserBookRepository->>UserBookEntity: toDomain(), fromDomain()
UserBookEntity-->>UserBookRepository: UserBook(readingRecordCount)
UserBookRepository-->>UserBookDomainService: UserBook(readingRecordCount)
UserBookDomainService-->>API: UserBookInfoVO(recordCount)
API-->>Client: UserBookResponse(recordCount)
sequenceDiagram
participant API
participant ReadingRecordDomainService
participant UserBookDomainService
API->>ReadingRecordDomainService: createReadingRecord(), findReadingRecordById(), ...
ReadingRecordDomainService->>UserBookDomainService: get userBook (for author, recordCount)
ReadingRecordDomainService-->>API: ReadingRecordInfoVO(author)
API-->>Client: ReadingRecordResponse(author)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–20 minutes Possibly related PRs
Suggested labels
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (10)
apis/src/main/kotlin/org/yapp/apis/book/dto/response/UserBookResponse.kt(2 hunks)apis/src/main/kotlin/org/yapp/apis/readingrecord/dto/response/ReadingRecordResponse.kt(2 hunks)domain/src/main/kotlin/org/yapp/domain/readingrecord/ReadingRecordDomainService.kt(5 hunks)domain/src/main/kotlin/org/yapp/domain/readingrecord/vo/ReadingRecordInfoVO.kt(3 hunks)domain/src/main/kotlin/org/yapp/domain/userbook/UserBook.kt(4 hunks)domain/src/main/kotlin/org/yapp/domain/userbook/UserBookDomainService.kt(2 hunks)domain/src/main/kotlin/org/yapp/domain/userbook/UserBookRepository.kt(1 hunks)domain/src/main/kotlin/org/yapp/domain/userbook/vo/UserBookInfoVO.kt(3 hunks)infra/src/main/kotlin/org/yapp/infra/userbook/entity/UserBookEntity.kt(3 hunks)infra/src/main/kotlin/org/yapp/infra/userbook/repository/impl/UserBookRepositoryImpl.kt(2 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-validation
🔇 Additional comments (10)
apis/src/main/kotlin/org/yapp/apis/book/dto/response/UserBookResponse.kt (1)
20-20: 새로운 recordCount 필드 추가 승인recordCount 필드가 올바르게 추가되었고, 팩토리 메서드에서 적절히 매핑되고 있습니다. 도메인 모델과의 일관성을 유지하는 좋은 구현입니다.
Also applies to: 37-37
domain/src/main/kotlin/org/yapp/domain/readingrecord/vo/ReadingRecordInfoVO.kt (1)
18-18: author 필드 추가 승인author 필드가 다른 선택적 필드들과 일관된 패턴으로 올바르게 추가되었습니다. newInstance 팩토리 메서드도 적절히 업데이트되었습니다.
Also applies to: 34-34, 48-48
infra/src/main/kotlin/org/yapp/infra/userbook/entity/UserBookEntity.kt (2)
69-71: readingRecordCount 필드 데이터베이스 매핑 승인새로운 readingRecordCount 필드가 적절한 데이터베이스 제약조건(nullable = false)과 기본값(0)으로 올바르게 매핑되었습니다. protected setter 사용도 기존 패턴과 일치합니다.
83-83: 도메인 변환 메서드 업데이트 승인toDomain() 메서드에 readingRecordCount 필드가 올바르게 포함되어 엔티티에서 도메인으로의 변환이 완전히 이루어집니다.
domain/src/main/kotlin/org/yapp/domain/userbook/vo/UserBookInfoVO.kt (1)
19-19: 독서 기록 수 필드 추가가 잘 구현되었습니다.
recordCount필드 추가와 관련된 변경사항들이 일관성 있게 잘 적용되었습니다. 특히 검증 로직에서 음수 값을 방지하는 부분이 좋습니다.Also applies to: 26-26, 35-35, 49-49
domain/src/main/kotlin/org/yapp/domain/userbook/UserBookDomainService.kt (1)
38-38: 일관된 매개변수 업데이트가 잘 이루어졌습니다.모든
UserBookInfoVO.newInstance호출에readingRecordCount매개변수가 일관되게 추가되어 새로운 필드가 올바르게 전파되고 있습니다.Also applies to: 49-49, 57-57, 62-62
apis/src/main/kotlin/org/yapp/apis/readingrecord/dto/response/ReadingRecordResponse.kt (1)
42-45: 저자 필드 추가가 적절하게 구현되었습니다.새로운
author필드가 nullable 타입으로 적절히 추가되었고, Swagger 문서화와 매핑 로직이 올바르게 구현되었습니다.Also applies to: 63-63
domain/src/main/kotlin/org/yapp/domain/userbook/UserBook.kt (1)
18-18: 독서 기록 수 추적 기능이 잘 구현되었습니다.
readingRecordCount필드와increaseReadingRecordCount()메서드가 적절히 추가되었습니다. 불변성을 유지하면서 카운트를 증가시키는 방식이 도메인 모델의 설계 원칙에 부합합니다.Also applies to: 27-29, 66-66, 81-81
domain/src/main/kotlin/org/yapp/domain/readingrecord/ReadingRecordDomainService.kt (2)
34-38: UserBook 조회 및 카운트 증가 로직이 잘 구현되었습니다.독서 기록 생성 시 UserBook 존재 여부를 확인하고 카운트를 증가시키는 로직이 적절히 구현되었습니다. 예외 처리도 명시적으로 잘 되어 있습니다.
Also applies to: 61-61
63-70: 저자 필드 추가가 일관되게 적용되었습니다.
ReadingRecordInfoVO에 저자 정보를 포함하도록 모든 관련 메서드가 일관되게 업데이트되었습니다.Also applies to: 95-97, 119-121
| return ReadingRecordInfoVO.newInstance( | ||
| readingRecord = savedReadingRecord, | ||
| emotionTags = tags.map { it.name }, | ||
| bookTitle = userBook?.title, | ||
| bookPublisher = userBook?.publisher, | ||
| bookCoverImageUrl = userBook?.coverImageUrl | ||
| bookTitle = userBook.title, | ||
| bookPublisher = userBook.publisher, | ||
| bookCoverImageUrl = userBook.coverImageUrl, | ||
| author = userBook.author | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
성능 최적화 고려사항
createReadingRecord 메서드에서 이미 UserBook을 조회했으므로, ReadingRecordInfoVO.newInstance 호출 시 재조회하는 대신 이미 가져온 userBook 객체를 직접 사용하는 것이 더 효율적일 수 있습니다.
현재는 buildReadingRecordInfoVO 메서드 내부에서 UserBook을 다시 조회하고 있습니다. 다음과 같이 리팩터링을 고려해보세요:
return ReadingRecordInfoVO.newInstance(
readingRecord = savedReadingRecord,
emotionTags = tags.map { it.name },
- bookTitle = userBook.title,
- bookPublisher = userBook.publisher,
- bookCoverImageUrl = userBook.coverImageUrl,
- author = userBook.author
+ bookTitle = userBook.title,
+ bookPublisher = userBook.publisher,
+ bookCoverImageUrl = userBook.coverImageUrl,
+ author = userBook.author
)또는 buildReadingRecordInfoVO 메서드를 오버로드하여 이미 조회된 UserBook을 받도록 수정할 수 있습니다.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In
domain/src/main/kotlin/org/yapp/domain/readingrecord/ReadingRecordDomainService.kt
around lines 63 to 70, the buildReadingRecordInfoVO method currently re-fetches
the UserBook even though it was already retrieved in createReadingRecord. To
optimize performance, refactor buildReadingRecordInfoVO to accept the already
fetched userBook as a parameter or overload it to do so, and use this passed
userBook directly instead of querying again.
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
불필요한 빈 줄 제거
인터페이스 끝에 추가된 빈 줄들이 불필요합니다. 코드 일관성을 위해 제거하는 것을 권장합니다.
-
-
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| } |
🤖 Prompt for AI Agents
In domain/src/main/kotlin/org/yapp/domain/userbook/UserBookRepository.kt at
lines 39 to 40, there are unnecessary blank lines at the end of the interface.
Remove these extra blank lines to maintain code consistency and cleanliness.
| ).apply { | ||
| this.readingRecordCount = userBook.readingRecordCount | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
도메인에서 엔티티로의 변환 로직 검증 필요
readingRecordCount가 apply 블록에서 설정되는 방식은 올바르지만, 이 카운트의 일관성 유지 방법을 확인해야 합니다. PR 목표에 따르면 현재는 읽기 기록 추가 시에만 증가하며, 향후 비즈니스 로직 검토가 필요하다고 명시되어 있습니다.
다음 사항들을 확인해 주세요:
- 읽기 기록 삭제 시 카운트 감소 로직이 구현되어 있는지
- 기존 데이터의 카운트 초기화 방법
- 카운트 불일치 발생 시 복구 방안
🏁 Script executed:
#!/bin/bash
# 읽기 기록 관련 increment/decrement 로직 확인
ast-grep --pattern 'incrementReadingRecordCount($_)'
ast-grep --pattern 'decrementReadingRecordCount($_)'
# ReadingRecord 삭제 관련 로직 확인
rg -A 5 "delete.*ReadingRecord"Length of output: 143
🏁 Script executed:
#!/bin/bash
# infra/src 및 도메인 계층 전반에서 readingRecordCount 키워드 검색
rg -n "readingRecordCount"
# 증감 메서드 명 확인
rg -n "incrementReadingRecordCount"
rg -n "decrementReadingRecordCount"
# 읽기 기록 추가/삭제 메서드 확인
rg -n "addReadingRecord"
rg -n "removeReadingRecord"
# DB 삭제 쿼리나 리포지토리 삭제 메서드 검색
rg -n "delete.*ReadingRecord"Length of output: 1675
ReadingRecordCount 동기화 로직 보완 필요
UserBookEntity의 readingRecordCount를 도메인에서 엔티티로 복사하는 부분은 정상적이나, 검색 결과 아래 내용이 확인되지 않았습니다.
• 삭제 시 감소 구현 부재
addReadingRecord()로 증가만 처리되고, 삭제할 때readingRecordCount를 감소시키는 메서드(removeReadingRecord()또는decrement…)가 코드베이스에 없습니다.- 비즈니스에서 읽기 기록 삭제를 허용한다면, 도메인·엔티티 양쪽에 감소 로직을 반드시 추가해야 합니다.
• 기존 데이터 초기화 방안 미확인
- DB 마이그레이션 또는 초기화 스크립트에서 기존 레코드의
reading_record_count컬럼을 백필(backfill)했는지 확인이 필요합니다. - 컬럼 추가 시 기본값이 0으로 설정되었다면 이미 생성된 레코드는 별도 처리 없이 0으로 초기화되었는지 검증해주세요.
• 불일치 복구 전략 부재
- 운영 중 카운트가 도메인·엔티티 간 불일치가 발생할 경우를 대비해, 정합성 체크 및 복구(예: 배치 작업, 스크립트)를 설계하고 문서화해야 합니다.
위 항목들을 반영하여 다음을 진행해주세요.
- 삭제 시
readingRecordCount--로직 추가 - DB 마이그레이션·백필 스크립트 검토/작성
- 정합성 체크 및 복구 플로우 정의
🤖 Prompt for AI Agents
In infra/src/main/kotlin/org/yapp/infra/userbook/entity/UserBookEntity.kt around
lines 101 to 103, the readingRecordCount is only incremented but lacks a
corresponding decrement method for when reading records are deleted. Add a
method like removeReadingRecord() to decrement readingRecordCount in both the
domain and entity layers. Additionally, review or create DB migration and
backfill scripts to ensure existing records have correct initial
readingRecordCount values. Finally, define and document a consistency check and
recovery process to handle any discrepancies between domain and entity counts
during operation.
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
불필요한 빈 줄 제거
클래스 끝에 추가된 빈 줄들이 불필요합니다. 코드 일관성을 위해 제거하는 것을 권장합니다.
-
}Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In
infra/src/main/kotlin/org/yapp/infra/userbook/repository/impl/UserBookRepositoryImpl.kt
at lines 84 to 85, there are unnecessary blank lines at the end of the class.
Remove these extra blank lines to maintain code consistency and cleanliness.
|


🔗 관련 이슈
📘 작업 유형
📙 작업 내역
UserBook도메인에readingRecordCount필드 추가readingRecordCount증가 처리 로직 추가UserBookEntity및UserBookRepository연동을 위한 필드 매핑 및 저장 처리 추가UserBookInfoVO,UserBookResponse등 응답 객체에recordCount필드 반영UserBookInfoVO.newInstance호출부 수정 (recordCount 전달)🧪 테스트 내역
recordCount가 증가하는지 확인🎨 스크린샷 또는 시연 영상 (선택)
✅ PR 체크리스트
💬 추가 설명 or 리뷰 포인트
recordCount가 증가하도록 되어 있습니다.recordCount일관성 유지를 위한 비즈니스 로직 점검 필요할 수 있습니다.Summary by CodeRabbit
신규 기능
버그 수정
기타 개선