Skip to content

[FEAT] 투표 API 기초 엔티티 세팅#196

Merged
coli-geonwoo merged 7 commits intodevelopfrom
feat/#195
Jul 10, 2025
Merged

[FEAT] 투표 API 기초 엔티티 세팅#196
coli-geonwoo merged 7 commits intodevelopfrom
feat/#195

Conversation

@coli-geonwoo
Copy link
Contributor

@coli-geonwoo coli-geonwoo commented Jul 10, 2025

🚩 연관 이슈

closed #195

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

  • VoteTeam은 도메인적으로 분리되어야 한다고 생각해서 Stance.PROS 와 분리했는데 합리적이라 생각하나요?

Summary by CodeRabbit

Summary by CodeRabbit

  • 신규 기능

    • 찬반 투표를 위한 투표(Poll) 및 투표(Vote) 데이터 관리 기능이 추가되었습니다.
    • 찬성팀과 반대팀 이름, 안건, 투표 상태 등을 저장 및 관리할 수 있습니다.
    • 각 투표에 참가자의 팀, 이름, 참가자 코드 정보를 기록할 수 있습니다.
  • 데이터베이스

    • 투표와 투표 결과를 저장하는 새로운 테이블이 추가되었습니다.

@coli-geonwoo coli-geonwoo linked an issue Jul 10, 2025 that may be closed by this pull request
@coderabbitai
Copy link

coderabbitai bot commented Jul 10, 2025

"""

Walkthrough

투표 기능을 위한 기초 엔티티가 도메인 및 엔티티 패키지에 새로 추가되었습니다. Poll과 Vote 관련 JPA 엔티티, 상태 및 팀 구분을 위한 Enum, 그리고 이에 맞는 DB 마이그레이션 스크립트가 도입되었습니다.

Changes

파일/경로 변경 요약
src/main/java/com/debatetimer/domain/poll/PollStatus.java 투표 상태를 나타내는 PollStatus enum(PROGRESS, DONE) 추가
src/main/java/com/debatetimer/domain/poll/VoteTeam.java 팀 구분용 빈 VoteTeam enum 추가
src/main/java/com/debatetimer/entity/poll/PollEntity.java 투표 정보를 저장하는 PollEntity JPA 엔티티 클래스 추가
src/main/java/com/debatetimer/entity/poll/VoteEntity.java 투표 기록을 저장하는 VoteEntity JPA 엔티티 클래스 추가
src/main/resources/db/migration/V9__create_poll_and_vote_table.sql poll, vote 테이블 생성 및 외래키 제약조건 추가 마이그레이션 추가

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PollEntity
    participant VoteEntity
    participant Database

    User->>PollEntity: 투표 생성 요청
    PollEntity->>Database: poll 테이블에 저장

    User->>VoteEntity: 투표 참여 요청
    VoteEntity->>Database: vote 테이블에 저장 (poll_id 참조)
Loading

Assessment against linked issues

Objective Addressed Explanation
투표 기능의 기초 Entity 세팅 (#195)

Assessment against linked issues: Out-of-scope changes

(해당 변경사항에는 명확히 범위를 벗어난 코드 변경이 없습니다.)
"""


📜 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 ffc3ad3 and 8ac9fd2.

📒 Files selected for processing (1)
  • src/main/resources/db/migration/V9__create_poll_and_vote_table.sql (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/resources/db/migration/V9__create_poll_and_vote_table.sql
⏰ 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

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 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 July 10, 2025 00:57
@unifolio0 unifolio0 added the feat 기능 추가 label Jul 10, 2025
@unifolio0 unifolio0 requested a review from leegwichan July 10, 2025 00:57
@github-actions
Copy link

github-actions bot commented Jul 10, 2025

📝 Test Coverage Report

Overall Project 84.59% 🍏
Files changed 100% 🍏

File Coverage
PollStatus.java 100% 🍏
VoteTeam.java 100% 🍏

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

🧹 Nitpick comments (1)
src/main/java/com/debatetimer/domain/poll/PollStatus.java (1)

5-7: enum 상수 명명 개선 제안

PROGRESS 보다는 IN_PROGRESS 또는 ACTIVE가 더 명확한 의미를 전달합니다. 또한 마지막 세미콜론이 불필요합니다.

 public enum PollStatus {
-    PROGRESS,
-    DONE,
-    ;
+    IN_PROGRESS,
+    DONE
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 51b9fd0 and 4842abd.

📒 Files selected for processing (5)
  • src/main/java/com/debatetimer/domain/poll/PollStatus.java (1 hunks)
  • src/main/java/com/debatetimer/domain/poll/VoteTeam.java (1 hunks)
  • src/main/java/com/debatetimer/entity/poll/PollEntity.java (1 hunks)
  • src/main/java/com/debatetimer/entity/poll/VoteEntity.java (1 hunks)
  • src/main/resources/db/migration/V9__create_poll_and_vote_table.sql (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-and-push
🔇 Additional comments (1)
src/main/resources/db/migration/V9__create_poll_and_vote_table.sql (1)

1-25: 데이터베이스 스키마 설계 양호

테이블 구조와 제약 조건이 잘 정의되어 있습니다. 외래키 제약 조건과 NOT NULL 제약 조건이 적절히 설정되어 있고, 엔티티 클래스와 일치합니다.

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

🧹 Nitpick comments (1)
src/main/java/com/debatetimer/domain/poll/VoteTeam.java (1)

7-7: 불필요한 세미콜론 제거 제안

enum 상수 뒤의 세미콜론은 메서드나 필드가 없을 때는 불필요합니다. 코드를 더 간결하게 만들 수 있습니다.

 public enum VoteTeam {
     PROS,
-    CONS,
-    ;
+    CONS
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4842abd and eaadfbc.

📒 Files selected for processing (1)
  • src/main/java/com/debatetimer/domain/poll/VoteTeam.java (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-and-push
🔇 Additional comments (1)
src/main/java/com/debatetimer/domain/poll/VoteTeam.java (1)

3-8: 이전 리뷰 이슈가 해결되었습니다.

빈 enum으로 인한 런타임 에러 가능성 문제가 해결되었습니다. PROSCONS 상수를 추가하여 토론 시스템의 찬성팀과 반대팀을 적절히 표현하고 있습니다.

@github-actions
Copy link

github-actions bot commented Jul 10, 2025

Test Results

 69 files   69 suites   11s ⏱️
187 tests 187 ✅ 0 💤 0 ❌
199 runs  199 ✅ 0 💤 0 ❌

Results for commit 8ac9fd2.

♻️ This comment has been updated with latest results.

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
리뷰 남겼어요

Comment on lines +32 to +36
@NotBlank
private String prosTeamName;

@NotBlank
private String consTeamName;
Copy link
Contributor

Choose a reason for hiding this comment

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

CustomizeTable에서 검증했기 때문에 여기선 검증하지 않는 건가요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네, 그렇게 판단한 이유는 다음과 같아요.

일단, 최대한 도메인 검증에 대한 책임은 Entity 단에서 수행하지 않는 것을 지향합니다.

선거 엔티티가 각 팀 이름을 검증하는 것이 어색하게 느껴졌습니다.

만약 팀이름에 대한 검증로직이 해당 엔티티에 추가되면 중복 검증이 되어 관리포인트가 2가지로 생깁니다.

따라서 생성 루트 일원화를 통해 관리하는 것이 바람직하다고 판단했습니다.

@Entity
@Table(name = "poll")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class PollEntity extends BaseTimeEntity {
Copy link
Contributor

Choose a reason for hiding this comment

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

이럴꺼면 CustomizeTimeBox에도 Entity 붙여주세요

Copy link
Member

Choose a reason for hiding this comment

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

@unifolio0 이건 다음에 작업하는 사람이 하는 걸로 합시다. 일단은 "투표 API 관련 엔티티"만 보는 건 어떨까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CustomizeTimeBox에도 도메인 -엔티티 분리 작업 리팩터링하면서 Entity suffix 붙을 것 같아요.

(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
table_id BIGINT NOT NULL,
status VARCHAR(255) NOT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

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

왜 다른 enum과 달리 얘는 varchar로 하셨나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

몰랐어요.

enum으로 변경해주었습니다.

(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
poll_id BIGINT NOT NULL,
team VARCHAR(255) NOT NULL,
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
Contributor Author

Choose a reason for hiding this comment

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

몰랐어요

enum으로 변경해주었습니다.

Comment on lines 9 to 10
created_at DATETIME(6) NOT NULL,
modified_at DATETIME(6) NOT NULL
Copy link
Contributor

Choose a reason for hiding this comment

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

여기 왜 다른 것과 달리 DATETIME로 하셨나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

몰랐어요.

timestamp로 변경해주었습니다.

Copy link
Member

@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 고생했고~ 일단은 비토가 코멘트 많이 남겨놔서 제가 더 달건 없을 것 같아요.
모든 코멘트 반영 후에 한 번 더 노티 주세요!

@Entity
@Table(name = "poll")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class PollEntity extends BaseTimeEntity {
Copy link
Member

Choose a reason for hiding this comment

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

@unifolio0 이건 다음에 작업하는 사람이 하는 걸로 합시다. 일단은 "투표 API 관련 엔티티"만 보는 건 어떨까요?

Copy link
Member

Choose a reason for hiding this comment

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

도메인 없이 일단 엔티티만 사용하는 건가요? 아니면 도메인은 다음 작업에서 구현하시는 건가요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[의견 🔈 ]

투표 API는 기존 도메인과 분리된 부분이기 때문에 영향 줄 부분이 크게 없다고 생각되어 API 뽑으면서 도메인까지 붙이겠습니다.

Copy link
Contributor Author

@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

리뷰 반영완료했습니다.

그리고 API 뽑으면서 도메인 객체 분리도 같이 진행하겠습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

[의견 🔈 ]

투표 API는 기존 도메인과 분리된 부분이기 때문에 영향 줄 부분이 크게 없다고 생각되어 API 뽑으면서 도메인까지 붙이겠습니다.

@Entity
@Table(name = "poll")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class PollEntity extends BaseTimeEntity {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

CustomizeTimeBox에도 도메인 -엔티티 분리 작업 리팩터링하면서 Entity suffix 붙을 것 같아요.

(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
table_id BIGINT NOT NULL,
status VARCHAR(255) NOT NULL,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

몰랐어요.

enum으로 변경해주었습니다.

Comment on lines 9 to 10
created_at DATETIME(6) NOT NULL,
modified_at DATETIME(6) NOT NULL
Copy link
Contributor Author

Choose a reason for hiding this comment

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

몰랐어요.

timestamp로 변경해주었습니다.

(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
poll_id BIGINT NOT NULL,
team VARCHAR(255) NOT NULL,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

몰랐어요

enum으로 변경해주었습니다.

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

♻️ Duplicate comments (1)
src/main/resources/db/migration/V9__create_poll_and_vote_table.sql (1)

5-5: 타 마이그레이션과 DATETIME/TIMESTAMP 사용 일관성 재검토 필요

이전 스키마에서 DATETIME 을 사용했던 컬럼들이 존재합니다. 동일 용도의 컬럼이면 형식을 통일해 주세요.
(과거 리뷰와 동일한 논의 사항입니다.)

🧹 Nitpick comments (2)
src/main/resources/db/migration/V9__create_poll_and_vote_table.sql (2)

13-17: vote.poll_id 에 인덱스가 없어 조인 성능이 저하될 수 있습니다

vote 테이블은 대부분 poll_id 조건으로 조회될 가능성이 높으므로 인덱스 추가를 권장합니다.

+CREATE INDEX idx_vote_poll_id ON vote (poll_id);

22-25: 외래 키에 ON DELETE CASCADE 옵션을 추가하면 데이터 정합성이 향상됩니다

poll 삭제 시 관련 vote 레코드를 자동으로 정리하지 않으면 불필요한 수작업이 필요합니다.

-    add constraint vote_to_poll
-        foreign key (poll_id)
-            references poll (id);
+    add constraint vote_to_poll
+        foreign key (poll_id)
+            references poll (id)
+            on delete cascade;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between eaadfbc and ffc3ad3.

📒 Files selected for processing (1)
  • src/main/resources/db/migration/V9__create_poll_and_vote_table.sql (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: coli-geonwoo
PR: debate-timer/debate-timer-be#196
File: src/main/java/com/debatetimer/entity/poll/VoteEntity.java:19-0
Timestamp: 2025-07-10T01:01:08.926Z
Learning: VoteEntity와 같은 JPA 엔티티에서 getter/setter 메서드는 필요할 때 점진적으로 추가하는 방식을 선호함. 초기 엔티티 설정 단계에서는 최소한의 구조만 유지하고 기능을 점진적으로 확장하는 개발 방식을 사용함.
⏰ 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

@unifolio0
Copy link
Contributor

/noti
@coli-geonwoo
바로 위에 토끼가 단 리뷰 반영해주면 머지해도 될 것 같습니다.

Copy link
Member

@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
Contributor Author

/noti

코드래빗 리뷰까지 반영하여 머지하겠습니다~

@coli-geonwoo coli-geonwoo merged commit 4c3baf5 into develop Jul 10, 2025
4 checks passed
@coli-geonwoo coli-geonwoo deleted the feat/#195 branch July 10, 2025 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat 기능 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 투표 기초 Entity 세팅

3 participants