Skip to content

Conversation

@CSE-Shaco
Copy link
Contributor

@CSE-Shaco CSE-Shaco commented Oct 21, 2025

📌 연관된 이슈

ex) #이슈번호, #이슈번호

✨ 작업 내용

refactor: 출석 관리 DB 스키마 및 서비스 구조 재정비(관계 정규화)

💬 리뷰 요구사항(선택)

Summary by CodeRabbit

릴리스 노트

  • 리팩토링
    • 출석 기록 관리 시스템의 데이터 구조를 개선했습니다. 날짜 기반에서 고유 ID 기반의 관계로 변경하여 데이터 일관성과 조회 성능을 향상시켰습니다.

- Meeting PK를 id(Long)로 전환, meeting_date는 UNIQUE 처리
- AttendanceRecord가 meeting_id FK로 Meeting을 참조하도록 변경
- Repository/Service 전반을 meetingId 기준으로 리팩터링
- 인덱스/제약 재정의로 조회/일관성 개선

BREAKING CHANGE: meeting_date를 PK로 사용하는 기존 쿼리/엔티티 매핑은 더 이상 유효하지 않습니다.
@coderabbitai
Copy link

coderabbitai bot commented Oct 21, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

출석 관리 도메인에서 LocalDate를 기반으로 하는 기본키 구조를 Meeting 엔티티의 관계 기반 구조로 리팩토링했습니다. Meeting에 서로게이트 키(Long id)를 추가하고, AttendanceRecordmeetingDate 필드를 Meeting과의 ManyToOne 관계로 변경하며, 관련 리포지토리 메서드들을 date 기반에서 meetingId 기반으로 마이그레이션했습니다.

Changes

코호트 / 파일 변경 요약
엔티티 리팩토링
src/main/java/inha/gdgoc/domain/core/attendance/entity/AttendanceRecord.java, src/main/java/inha/gdgoc/domain/core/attendance/entity/Meeting.java
AttendanceRecord에서 meetingDate 필드를 Meeting으로의 @manytoone 관계로 교체; 유니크 제약 및 인덱스를 date 기반에서 meeting_id 기반으로 변경. Meeting에 서로게이트 키 id 추가, meeting_date에 유니크 제약 조건 및 인덱스 추가.
리포지토리 메서드 변경
src/main/java/inha/gdgoc/domain/core/attendance/repository/AttendanceRecordRepository.java
메서드 시그니처를 date 기반에서 meetingId 기반으로 변경: findPresencePairsByDate()findPresencePairsByMeetingId(), deleteByMeetingDate()deleteByMeeting_Id(), upsertBatch()upsertBatchByMeetingId(). SQL 쿼리 및 파라미터 업데이트. 임포트 정리.
MeetingRepository 업데이트
src/main/java/inha/gdgoc/domain/core/attendance/repository/MeetingRepository.java
제네릭 타입을 JpaRepository<Meeting, LocalDate>에서 JpaRepository<Meeting, Long>로 변경. findByMeetingDate(LocalDate meetingDate) 메서드 추가.
서비스 로직 리팩토링
src/main/java/inha/gdgoc/domain/core/attendance/service/CoreAttendanceService.java
date 기반 작업을 meetingId 기반으로 전환. 새로운 헬퍼 메서드 ensureMeetingAndGetId(LocalDate date) 추가. addDate(), deleteDate(), setAttendance(), getPresenceMap() 메서드 로직 업데이트.

Sequence Diagram(s)

sequenceDiagram
    participant Client as 클라이언트
    participant Service as CoreAttendanceService
    participant MeetingRepo as MeetingRepository
    participant AttendanceRepo as AttendanceRecordRepository
    participant DB as 데이터베이스

    rect rgb(200, 220, 240)
    Note over Service,DB: 변경 전 (date 기반)
    Client->>Service: addDate(date)
    Service->>DB: INSERT Meeting WHERE meetingDate = ?
    end

    rect rgb(220, 240, 200)
    Note over Service,DB: 변경 후 (meetingId 기반)
    Client->>Service: addDate(date)
    Service->>MeetingRepo: findByMeetingDate(date)
    MeetingRepo->>DB: SELECT * FROM meetings WHERE meeting_date = ?
    alt Meeting 없음
        Service->>Service: CREATE new Meeting
        Service->>MeetingRepo: save(meeting)
        MeetingRepo->>DB: INSERT INTO meetings
        DB-->>MeetingRepo: id 반환
    end
    MeetingRepo-->>Service: Meeting with id
    Service-->>Client: complete
    end

    rect rgb(240, 220, 200)
    Note over Service,DB: 출석 정보 저장 흐름 (변경 후)
    Client->>Service: setAttendance(date, userIds, present)
    Service->>Service: ensureMeetingAndGetId(date)
    Service->>AttendanceRepo: upsertBatchByMeetingId(meetingId, ...)
    AttendanceRepo->>DB: UPSERT attendance_records ON CONFLICT (meeting_id, user_id)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60분

사유: 도메인 구조의 핵심적 변경으로, 엔티티의 기본키 전략, 관계 매핑, 데이터베이스 제약 조건, 리포지토리 쿼리 로직, 서비스 비즈니스 로직이 모두 영향을 받습니다. 각 파일의 변경이 서로 밀접하게 연계되어 있으므로 전체 흐름을 이해하고 일관성을 검증해야 합니다.

Possibly related PRs

Poem

🐰 날짜는 이제 과거, ID가 주인공!
Meeting과 손잡고 춤을 춘다네,
데이터는 더욱 정결해지고,
제약조건은 더욱 튼튼해지고,
리팩토링의 우아한 마법! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 564e907 and 0b10eb1.

📒 Files selected for processing (5)
  • src/main/java/inha/gdgoc/domain/core/attendance/entity/AttendanceRecord.java (2 hunks)
  • src/main/java/inha/gdgoc/domain/core/attendance/entity/Meeting.java (1 hunks)
  • src/main/java/inha/gdgoc/domain/core/attendance/repository/AttendanceRecordRepository.java (1 hunks)
  • src/main/java/inha/gdgoc/domain/core/attendance/repository/MeetingRepository.java (1 hunks)
  • src/main/java/inha/gdgoc/domain/core/attendance/service/CoreAttendanceService.java (3 hunks)

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@CSE-Shaco CSE-Shaco merged commit 272e1df into GDGoCINHA:develop Oct 21, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant