Skip to content

[REFACTOR] CustomizeTimeBoxEntities 제거#214

Merged
leegwichan merged 5 commits intodevelopfrom
refactor/#213
Aug 10, 2025
Merged

[REFACTOR] CustomizeTimeBoxEntities 제거#214
leegwichan merged 5 commits intodevelopfrom
refactor/#213

Conversation

@leegwichan
Copy link
Member

@leegwichan leegwichan commented Aug 5, 2025

🚩 연관 이슈

closed #213

🗣️ 리뷰 요구사항 (선택)

  • Entity 여러개 -> Domain 여러개 로직을 DomainRepository에서 진행했습니다.
    • 해당 로직을 사용하는 곳이 한 곳이라서 DomainRepository에 두어도 문제 없다고 생각했습니다.

Summary by CodeRabbit

  • Refactor

    • 내부 구조를 단순화하고 불필요한 클래스를 제거하여 코드 유지보수성을 향상시켰습니다.
  • Tests

    • 시간박스와 벨의 순서 및 연관 관계를 검증하는 테스트가 추가되었습니다.
    • 사용되지 않는 테스트 코드가 삭제되었습니다.

@coderabbitai
Copy link

coderabbitai bot commented Aug 5, 2025

Walkthrough

CustomizeTimeBoxEntities 래퍼 클래스가 삭제되었으며, 관련 엔티티-도메인 변환 로직이 CustomizeTableDomainRepository의 프라이빗 헬퍼 메서드로 대체되었습니다. 이에 따라 DTO, 리포지토리, 테스트 코드 등에서 해당 클래스 및 관련 메서드, 생성자, 테스트가 모두 제거되었습니다.

Changes

Cohort / File(s) Change Summary
CustomizeTimeBoxEntities 래퍼 및 테스트 제거
src/main/java/com/debatetimer/entity/customize/CustomizeTimeBoxEntities.java, src/test/java/com/debatetimer/entity/customize/CustomizeTimeBoxEntitiesTest.java
CustomizeTimeBoxEntities 클래스 및 관련 단위 테스트 파일 삭제
도메인 리포지토리 리팩토링
src/main/java/com/debatetimer/domainrepository/customize/CustomizeTableDomainRepository.java
CustomizeTimeBoxEntities 사용 제거, 엔티티-도메인 변환을 위한 프라이빗 헬퍼 메서드(toCustomizeTimeBoxes, toTimeBox) 추가
DTO 생성자 및 메서드 정리
src/main/java/com/debatetimer/dto/customize/response/CustomizeTableResponse.java
CustomizeTimeBoxEntities 기반 생성자 및 관련 헬퍼 메서드 제거, 불필요한 import 삭제
CustomizeTimeBoxRepository 인터페이스 단순화
src/main/java/com/debatetimer/repository/customize/CustomizeTimeBoxRepository.java
CustomizeTimeBoxEntities 관련 default 메서드(saveAll, findTableTimeBoxes) 및 import 삭제
도메인 리포지토리 테스트 보강
src/test/java/com/debatetimer/domainrepository/customize/CustomizeTableDomainRepositoryTest.java
시간박스 순서 검증 테스트 확장 및 벨 포함 조회 테스트 추가
테스트용 엔티티 생성기 확장
src/test/java/com/debatetimer/fixture/entity/CustomizeTimeBoxEntityGenerator.java
시간 값을 파라미터로 받는 오버로드된 generate 메서드 추가

Sequence Diagram(s)

(생성할 시나리오가 단순한 내부 변환 로직 리팩토링에 불과하므로 시퀀스 다이어그램 생략)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
CustomizeTimeBoxEntities 제거 (#213)

Assessment against linked issues: Out-of-scope changes

(요구사항 외 변경사항 없음)

Possibly related PRs

Suggested reviewers

  • coli-geonwoo

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.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49b38fc and 8581c4d.

📒 Files selected for processing (1)
  • src/test/java/com/debatetimer/domainrepository/customize/CustomizeTableDomainRepositoryTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/com/debatetimer/domainrepository/customize/CustomizeTableDomainRepositoryTest.java
⏰ 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-and-push
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/#213

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.

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.

@unifolio0 unifolio0 self-requested a review August 5, 2025 06:05
@unifolio0 unifolio0 added the refactor 리팩토링 label Aug 5, 2025
@unifolio0 unifolio0 requested a review from coli-geonwoo August 5, 2025 06:05
@github-actions
Copy link

github-actions bot commented Aug 5, 2025

Test Results

119 files  119 suites   14s ⏱️
272 tests 272 ✅ 0 💤 0 ❌
284 runs  284 ✅ 0 💤 0 ❌

Results for commit 8581c4d.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Aug 5, 2025

📝 Test Coverage Report

Overall Project 87.7% 🍏
Files changed 100% 🍏

File Coverage
CustomizeTableDomainRepository.java 100% 🍏

Copy link
Contributor

@coli-geonwoo coli-geonwoo left a comment

Choose a reason for hiding this comment

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

/noti

커찬, 빠른 작업 감사합니다 🙇 간단한 몇가지 생각남겼슴다. 바쁜 거 아니까 천천히 리뷰해주세요. 의견 듣고 싶어 일단 RC로 둘게요!

.toList();
}

@Transactional
Copy link
Contributor

Choose a reason for hiding this comment

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

[제안]

isContained로 O(N)으로 계속 탐색하는게 마음에 들지 않아서 + 해석해야 할 로직이 많은 것 같아 스트림 최대한 활용해본 건데 커찬 기호에 맞게 도입해도 좋을 것 같아요. 지금 커찬 로직도 좋은 것 같아요.

    private List<CustomizeTimeBox> toCustomizeTimeBoxes2(
            List<CustomizeTimeBoxEntity> timeBoxEntities,
            List<BellEntity> bellEntities
    ) {
        Map<Long, List<BellEntity>> groupingBellEntities =  bellEntities.stream()
                .collect(Collectors.groupingBy(bellEntity -> bellEntity.getCustomizeTimeBox().getId()));
        return timeBoxEntities.stream()
                .map(timeBox -> toTimeBox(timeBox, groupingBellEntities.get(timeBox.getId())))
                .toList();
    }
    
    private CustomizeTimeBox toTimeBox(CustomizeTimeBoxEntity timeBoxEntity, List<BellEntity> bellEntities) {
        return bellEntities.stream()
                .map(BellEntity::toDomain)
                .collect(Collectors.collectingAndThen(Collectors.toList(), timeBoxEntity::toDomain));
    }

Copy link
Member Author

Choose a reason for hiding this comment

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

반영했습니다~

.toList();
}

private List<Bell> getBells(CustomizeTimeBoxEntity timeBox, List<BellEntity> bells) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[사소한 제안]

엔티티랑 도메인이랑 분리되면서 필드명에서도 timeBoxEntity, bellEntities 처럼 엔티티는 엔티티 suffix를 붙여도 좋을 것 같은데 어떤가요?

private List<CustomizeTimeBox> toCustomizeTimeBoxes(List<CustomizeTimeBoxEntity> timeBoxEntities,
List<BellEntity> bellEntities) {
return timeBoxEntities.stream()
.map(timebox -> timebox.toDomain(getBells(timebox, bellEntities)))
Copy link
Contributor

@coli-geonwoo coli-geonwoo Aug 5, 2025

Choose a reason for hiding this comment

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

[typo]

Suggested change
.map(timebox -> timebox.toDomain(getBells(timebox, bellEntities)))
.map(timeBox -> timeBox.toDomain(getBells(timebox, bellEntities)))

return toCustomizeTimeBoxes(timeBoxEntityList, bellEntityList);
}

private List<CustomizeTimeBox> toCustomizeTimeBoxes(List<CustomizeTimeBoxEntity> timeBoxEntities,
Copy link
Contributor

Choose a reason for hiding this comment

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

[개인적인 느낌]

지금은 충분히 용납가능한 수준이지만 Domain Repository에 List로 매핑하는 메서드가 3개 이상되다 보니까 타고타고 들어가서 로직을 보게 되는 경향이 있는 것 같아요.

내가 코드를 읽었던 흐름 : getCustomizeTimeBoxes > toCustomizetimeBoxes > getBells > 다시 toCustomizeTimeBoxes로 돌아와 로직 이해

이건 어떤가요? CustomizeTimeBoxes를 만들고
CustomizeTimeBoxes(List customizeTimeBoxes, List bells) 로 생성자를 열되 지금 있는 매핑 로직을 도메인 일급 컬렉션에 넣는 거에요.

도메인 단의 일급 컬렉션은 타임박스들의 연속된 배열을 하나의 객체로 바라보고 역할을 분담해 줄 수 있다는 점에서 매력적인 것 같아서요. 아마 커찬은 꺼려할 것 같긴 한데 한번 고려해주세유 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

이거는 대형 공사가 되서... (메서드 시그니처 바꾸려면, 서비스부터 도메인 레포지토리 테스트까지 전부 바꿔야 함)
PR 나눠서 진행해야 될 것 같아요. 다음 스프린트 TODO List에 넣어놓을께요~!

class CustomizeTimeBoxEntitiesTest {

@Nested
class SortedBySequence {
Copy link
Contributor

Choose a reason for hiding this comment

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

[질문]

혹시 이 테스트를 옮기지 않고 그냥 삭제만 한 이유 물어봐도 되나요?

Copy link
Member Author

Choose a reason for hiding this comment

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

CustomizeTableDomainRepositoryTest > GetCustomizeTimeBoxes > 테이블의_시간박스는_순서대로_가져온다()
해당 테스트에 반영했습니다~

Copy link
Contributor

@unifolio0 unifolio0 left a comment

Choose a reason for hiding this comment

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

/noti
@leegwichan
콜리 의견만 확인해주면 제가 더 이상 언급할 건 없는 것 같아요. approe하겠습니다.

Copy link
Member Author

@leegwichan leegwichan left a comment

Choose a reason for hiding this comment

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

/noti @coli-geonwoo
일부 반영했습니다~ 리뷰 부탁드려요

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 (1)
src/test/java/com/debatetimer/fixture/entity/CustomizeTimeBoxEntityGenerator.java (1)

32-46: 오버로드 추가는 적절합니다. 기본 메서드로 위임해 중복을 제거하세요.

현재 두 generate 메서드가 거의 동일한 객체 생성 로직을 중복합니다. DRY 관점에서 기본값(180초)을 사용하는 기존 메서드가 새 오버로드로 위임하도록 정리하면 유지보수가 쉬워집니다. 또한 180, "입론", "콜리" 등 매직 리터럴은 상수로 추출해 의미를 드러내는 것도 권장합니다.

기존 메서드(변경 범위 밖) 예시:

public CustomizeTimeBoxEntity generate(CustomizeTableEntity testTable, CustomizeBoxType boxType, int sequence) {
    return generate(testTable, boxType, sequence, 180);
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5f917eb and 49b38fc.

📒 Files selected for processing (3)
  • src/main/java/com/debatetimer/domainrepository/customize/CustomizeTableDomainRepository.java (2 hunks)
  • src/test/java/com/debatetimer/domainrepository/customize/CustomizeTableDomainRepositoryTest.java (1 hunks)
  • src/test/java/com/debatetimer/fixture/entity/CustomizeTimeBoxEntityGenerator.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/debatetimer/domainrepository/customize/CustomizeTableDomainRepository.java
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: leegwichan
PR: debate-timer/debate-timer-be#198
File: src/test/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomainTest.java:82-112
Timestamp: 2025-07-15T01:28:24.899Z
Learning: CustomizeTimeBoxDomain 클래스에서는 생성자에서 stance null 검증을 먼저 수행한 후 isValidStance() 추상 메서드를 호출하는 구조로 되어 있어, 테스트용 구현체에서 isValidStance()는 단순히 true를 반환해도 된다.
Learnt from: leegwichan
PR: debate-timer/debate-timer-be#198
File: src/test/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomainTest.java:82-112
Timestamp: 2025-07-15T01:28:24.899Z
Learning: CustomizeTimeBoxDomain에서 validateStance 메서드는 null 체크를 먼저 수행한 후에 isValidStance() 추상 메서드를 호출하는 구조로, 테스트용 구현체에서 isValidStance()가 단순히 true를 반환하는 것이 적절하다.
Learnt from: leegwichan
PR: debate-timer/debate-timer-be#201
File: src/main/java/com/debatetimer/entity/customize/BellEntity.java:50-54
Timestamp: 2025-07-18T01:04:20.985Z
Learning: BellEntity에서는 도메인 레벨에서 이미 유효성 검사가 수행되므로 엔티티 레벨의 유효성 검사는 중복이며, 향후 엔티티의 유효성 검사를 제거할 예정이다.
📚 Learning: 2025-07-15T01:28:24.899Z
Learnt from: leegwichan
PR: debate-timer/debate-timer-be#198
File: src/test/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomainTest.java:82-112
Timestamp: 2025-07-15T01:28:24.899Z
Learning: CustomizeTimeBoxDomain 클래스에서는 생성자에서 stance null 검증을 먼저 수행한 후 isValidStance() 추상 메서드를 호출하는 구조로 되어 있어, 테스트용 구현체에서 isValidStance()는 단순히 true를 반환해도 된다.

Applied to files:

  • src/test/java/com/debatetimer/fixture/entity/CustomizeTimeBoxEntityGenerator.java
  • src/test/java/com/debatetimer/domainrepository/customize/CustomizeTableDomainRepositoryTest.java
📚 Learning: 2025-07-15T01:28:24.899Z
Learnt from: leegwichan
PR: debate-timer/debate-timer-be#198
File: src/test/java/com/debatetimer/domain/customize/CustomizeTimeBoxDomainTest.java:82-112
Timestamp: 2025-07-15T01:28:24.899Z
Learning: CustomizeTimeBoxDomain에서 validateStance 메서드는 null 체크를 먼저 수행한 후에 isValidStance() 추상 메서드를 호출하는 구조로, 테스트용 구현체에서 isValidStance()가 단순히 true를 반환하는 것이 적절하다.

Applied to files:

  • src/test/java/com/debatetimer/fixture/entity/CustomizeTimeBoxEntityGenerator.java
  • src/test/java/com/debatetimer/domainrepository/customize/CustomizeTableDomainRepositoryTest.java
⏰ 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-and-push

Copy link
Contributor

@coli-geonwoo coli-geonwoo left a comment

Choose a reason for hiding this comment

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

/noti

@leegwichan

커찬, 별다른 리뷰 사안 없고, 잘 반영해준 것 같아요. approve 합니다~

@leegwichan leegwichan merged commit ad15ffb into develop Aug 10, 2025
4 checks passed
@leegwichan leegwichan deleted the refactor/#213 branch August 10, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] CustomizeTimeBoxEntities 제거

3 participants