Skip to content

Conversation

@minwoo1999
Copy link
Member

@minwoo1999 minwoo1999 commented Jul 31, 2025

🔗 관련 이슈

📘 작업 유형

  • ✨ Feature (기능 추가)
  • 🐞 Bugfix (버그 수정)
  • 🔧 Refactor (코드 리팩토링)
  • ⚙️ Chore (환경 설정)
  • 📝 Docs (문서 작성 및 수정)
  • ✅ Test (기능 테스트)
  • 🎨 style (코드 스타일 수정)

📙 작업 내역

  • BookSearchResponsefrom(updatedBooks: List<BookSummary>) 함수 추가
  • 책 검색 결과에 사용자 상태(BookStatus)를 반영하도록 BookUseCase 수정
  • 기본 상태를 BEFORE_READINGBEFORE_REGISTRATION으로 변경
  • BookStatus enum에 BEFORE_REGISTRATION 상태 추가

🧪 테스트 내역

  • 브라우저/기기에서 동작 확인
  • 엣지 케이스 테스트 완료
  • 기존 기능 영향 없음

🎨 스크린샷 또는 시연 영상 (선택)

(해당 사항 없음)

✅ PR 체크리스트

  • 커밋 메시지가 명확합니다
  • PR 제목이 컨벤션에 맞습니다
  • 관련 이슈 번호를 작성했습니다
  • 기능이 정상적으로 작동합니다
  • 불필요한 코드를 제거했습니다

💬 추가 설명 or 리뷰 포인트 (선택)

  • BookSearchResponse에 기존 인스턴스를 기반으로 새로운 리스트를 반영하는 from() 메서드를 도입해 불변성을 유지했습니다.
  • 사용자 도서 상태가 없는 경우 BEFORE_REGISTRATION으로 초기화되도록 처리했습니다.

Summary by CodeRabbit

  • 신규 기능

    • 도서 상태에 "등록 전(BEFORE_REGISTRATION)" 상태가 추가되었습니다.
  • 버그 수정

    • 도서 검색 시 기본 도서 상태가 "읽기 전"에서 "등록 전"으로 변경되었습니다.
  • 기타

    • 도서 검색 결과의 상태 업데이트 방식이 개선되어, 보다 정확한 상태 반영이 가능합니다.

@coderabbitai
Copy link

coderabbitai bot commented Jul 31, 2025

📝 Walkthrough

Walkthrough

BookStatus enum에 BEFORE_REGISTRATION이 새로 추가되었습니다. BookSearchResponseBookSummary에서 기본 상태가 BEFORE_READING에서 BEFORE_REGISTRATION으로 변경되었고, 리스트를 복사해 새로운 응답을 생성하는 from 메서드가 추가되었습니다. BookUseCasesearchBooks는 리스트를 불변적으로 갱신하여 반환하도록 수정되었습니다.

Changes

Cohort / File(s) Change Summary
BookStatus Enum 확장
domain/src/main/kotlin/org/yapp/domain/userbook/BookStatus.kt
BEFORE_REGISTRATION enum 상수 추가
BookSearchResponse 개선
apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookSearchResponse.kt
BookSearchResponsefrom(updatedBooks: List<BookSummary>) 메서드 추가, BookSummary.fromAladinItem의 기본 userBookStatusBEFORE_REGISTRATION으로 변경
BookUseCase 불변성 개선
apis/src/main/kotlin/org/yapp/apis/book/usecase/BookUseCase.kt
searchBooks에서 기존 리스트를 직접 수정하지 않고, map을 통해 새로운 리스트를 생성 후 from으로 새 응답 객체 반환

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BookUseCase
    participant BookSearchResponse

    User->>BookUseCase: searchBooks()
    BookUseCase->>BookSearchResponse: BookSearchResponse.fromAladinItem()
    BookUseCase->>BookSearchResponse: from(updatedBooks)
    BookUseCase-->>User: BookSearchResponse (with updated userBookStatus)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
userBookStatus에 등록 전 enum 추가 (#60)

Possibly related PRs

Suggested reviewers

  • hoonyworld

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch BOOK-191-feature/#60

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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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.

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.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82f0a61 and 5d7e3ae.

📒 Files selected for processing (3)
  • apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookSearchResponse.kt (2 hunks)
  • apis/src/main/kotlin/org/yapp/apis/book/usecase/BookUseCase.kt (1 hunks)
  • domain/src/main/kotlin/org/yapp/domain/userbook/BookStatus.kt (1 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 (3)
domain/src/main/kotlin/org/yapp/domain/userbook/BookStatus.kt (1)

4-4: enum 순서 변경 안전 확인

BookStatus enum은 데이터베이스에 문자열(EnumType.STRING)로 저장되며, 코드 전반에서 ordinal() 호출이나 ordinal 기반 비교를 찾을 수 없었습니다.
따라서 BEFORE_REGISTRATION를 맨 앞에 추가하더라도 기존 데이터나 로직에 영향이 없습니다.

  • infra/src/main/kotlin/org/yapp/infra/userbook/entity/UserBookEntity.kt: @Enumerated(EnumType.STRING) 사용 확인
apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookSearchResponse.kt (1)

81-81: 기본 상태 변경이 적절함

BEFORE_READING에서 BEFORE_REGISTRATION으로 기본 상태를 변경한 것이 논리적으로 적절합니다. 사용자가 아직 책을 등록하지 않은 초기 상태를 정확히 표현합니다.

apis/src/main/kotlin/org/yapp/apis/book/usecase/BookUseCase.kt (1)

47-53: 함수형 접근으로의 우수한 리팩토링

mutable한 forEach 루프를 immutable한 map 연산으로 리팩토링한 것이 훌륭합니다. 이 변경으로 다음과 같은 이점을 얻었습니다:

  • 불변성 보장으로 사이드 이펙트 제거
  • 함수형 프로그래밍 스타일 적용
  • let을 사용한 null-safe 처리로 안전성 향상
  • 새로운 from 메서드와 잘 통합됨

Comment on lines +22 to +36
fun from(updatedBooks: List<BookSummary>): BookSearchResponse {
return BookSearchResponse(
version = this.version,
title = this.title,
link = this.link,
pubDate = this.pubDate,
totalResults = this.totalResults,
startIndex = this.startIndex,
itemsPerPage = this.itemsPerPage,
query = this.query,
searchCategoryId = this.searchCategoryId,
searchCategoryName = this.searchCategoryName,
books = updatedBooks
)
}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

data class의 copy() 메서드 활용으로 간소화 가능

새로운 from 메서드의 구현은 올바르지만, data class의 내장 copy() 메서드를 사용하면 더 간결하게 작성할 수 있습니다.

다음과 같이 리팩토링할 수 있습니다:

-    fun from(updatedBooks: List<BookSummary>): BookSearchResponse {
-        return BookSearchResponse(
-            version = this.version,
-            title = this.title,
-            link = this.link,
-            pubDate = this.pubDate,
-            totalResults = this.totalResults,
-            startIndex = this.startIndex,
-            itemsPerPage = this.itemsPerPage,
-            query = this.query,
-            searchCategoryId = this.searchCategoryId,
-            searchCategoryName = this.searchCategoryName,
-            books = updatedBooks
-        )
-    }
+    fun from(updatedBooks: List<BookSummary>): BookSearchResponse {
+        return this.copy(books = updatedBooks)
+    }
🤖 Prompt for AI Agents
In apis/src/main/kotlin/org/yapp/apis/book/dto/response/BookSearchResponse.kt
around lines 22 to 36, the from() method manually copies all properties to
create a new instance. Refactor this method to use the data class's built-in
copy() function with the updatedBooks list as the only changed property, which
simplifies the code and reduces redundancy.

@minwoo1999 minwoo1999 changed the title Book 191 feature/#60 feat: userBookStatus에 등록 전 enum 추가 Jul 31, 2025
@minwoo1999 minwoo1999 merged commit 0ee57fc into develop Jul 31, 2025
6 of 7 checks passed
@move-hoon move-hoon deleted the BOOK-191-feature/#60 branch August 12, 2025 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BOOK-191/feat] userBookStatus에 등록 전 enum 추가

2 participants