Skip to content

fix: 대학별 동아리 수를 대학 응답에 분리#640

Merged
dh2906 merged 1 commit into
developfrom
fix/university-club-total-count
May 26, 2026
Merged

fix: 대학별 동아리 수를 대학 응답에 분리#640
dh2906 merged 1 commit into
developfrom
fix/university-club-total-count

Conversation

@dh2906
Copy link
Copy Markdown
Contributor

@dh2906 dh2906 commented May 26, 2026

🔍 개요

  • 대학별 동아리 목록에서 분과 필터를 선택해도 대학교 자체의 전체 동아리 수를 university.clubCount로 확인할 수 있도록 수정했습니다.

🚀 주요 변경 내용

  • totalCount는 기존처럼 현재 검색어/분과 필터가 적용된 목록 개수로 유지했습니다.
  • 필터와 무관한 대학 전체 동아리 수를 university.clubCount 필드로 분리했습니다.
  • 대학 전체 동아리 수 조회는 기존 공통 동아리 조건을 재사용해 카운트 조건이 따로 drift되지 않도록 했습니다.

💬 참고 사항

  • ./gradlew test --tests 'gg.agit.konect.integration.domain.website.WebsiteApiTest' 통과했습니다.
  • push 전 hook에서 checkstyleMain, compileJava가 통과했습니다.

✅ Checklist (완료 조건)

  • 코드 스타일 가이드 준수
  • 테스트 코드 포함됨
  • Reviewers / Assignees / Labels 지정 완료
  • 보안 및 민감 정보 검증 (API 키, 환경 변수, 개인정보 등)

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

페이지네이션 결과에서 총 개수를 계산하던 방식을 개선하여, 별도의 카운트 쿼리로 조회한 값을 응답에 포함하도록 변경합니다. DTO 시그니처, Repository 조건, Service 호출이 함께 업데이트되고 통합 테스트로 검증됩니다.

Changes

대학별 클럽 수 카운트 계산 개선

Layer / File(s) Summary
응답 DTO 계약 업데이트
src/main/java/gg/agit/konect/domain/website/dto/WebsiteClubsResponse.java
WebsiteClubsResponse.of 메서드에 Long totalCount 매개변수가 추가되고, 응답 생성 시 page.getTotalElements() 대신 전달받은 totalCount 값으로 할당됩니다.
클럽 카운트 쿼리 조건 리팩토링
src/main/java/gg/agit/konect/domain/website/repository/WebsiteQueryRepository.java
countClubsByUniversityId의 count 쿼리 where 조건이 직접 작성한 webClub.university.id.eq(universityId)에서 공통 헬퍼 메서드 createClubCondition(universityId, null, null)으로 변경되어 조건 구성의 일관성을 확보합니다.
서비스 통합 및 테스트 검증
src/main/java/gg/agit/konect/domain/website/service/WebsiteService.java, src/test/java/gg/agit/konect/integration/domain/website/WebsiteApiTest.java
Service의 getUniversityClubs에서 WebsiteClubsResponse.of 호출 시 countClubsByUniversityId 결과를 새로운 totalCount 인자로 전달합니다. 통합 테스트의 DisplayName과 기대값이 업데이트되어 대학 전체 동아리 수 반환(13)을 검증합니다.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • BCSDLab/KONECT_BACK_END#632: 동일한 countClubsByUniversityId 메서드를 사용하여 대학별 전체 동아리 수를 조회하고, 응답 DTO에 매핑하는 코드 흐름이 겹칩니다.

Suggested labels

Hotfix

Poem

🐰 페이지에서 숫자를 세던 토끼,
이제 데이터베이스에 직접 묻는다네.
쿼리 조건을 정리하니 깔끔하고,
대학별 동아리 수, 정확히 세어지네!
테스트도 업데이트되어 모두 맞춘다. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed PR 제목이 변경의 핵심을 명확하게 설명합니다. 대학별 동아리 수를 필터와 분리한다는 주요 의도가 잘 드러나 있습니다.
Description check ✅ Passed PR 설명이 변경사항과 관련이 있으며, 개요, 주요 변경 내용, 테스트 결과를 포함합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/university-club-total-count

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 26, 2026

🧪 JaCoCo Coverage Report (Changed Files)

Summary

  • Overall Coverage: 97.5% ✅
  • Covered Lines: 116 / 119
  • Changed Files: 3

Coverage by File

Class Coverage Lines Status
WebsiteQueryRepository
gg.agit.konect.domain.website.repository
96.7% 88/91
WebsiteService
gg.agit.konect.domain.website.service
100.0% 28/28

📊 View Workflow Run

- 대학별 동아리 목록에서 totalCount는 필터링된 목록 개수로 유지해 기존 페이지네이션 의미를 보존

- 대학 전체 동아리 수는 university.clubCount로 분리해 분과 필터와 무관한 대학 요약값으로 제공

- 전체 동아리 수 카운트는 기존 공통 동아리 조건을 재사용해 조회 조건이 drift되지 않도록 정리
@dh2906 dh2906 force-pushed the fix/university-club-total-count branch from df2439d to a9bc223 Compare May 26, 2026 13:15
@dh2906 dh2906 changed the title fix: 대학별 동아리 전체 수를 필터와 분리 fix: 대학별 동아리 수를 대학 응답에 분리 May 26, 2026
Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/gg/agit/konect/domain/website/dto/WebsiteClubsResponse.java`:
- Around line 127-135: The of factory (WebsiteClubsResponse.of) currently
injects totalCount into the response without null-checks; add a null-safety
guard to prevent null from being serialized for the `@Schema`(requiredMode =
REQUIRED) totalCount field — call Objects.requireNonNull(totalCount, "totalCount
must not be null") (or change the DTO/parameter to primitive long) before
constructing WebsiteClubsResponse so null cannot flow into the response.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 67b4b3fa-61c1-4523-8ba3-6ba5e5dbeb6f

📥 Commits

Reviewing files that changed from the base of the PR and between 0c2c476 and df2439d.

📒 Files selected for processing (4)
  • src/main/java/gg/agit/konect/domain/website/dto/WebsiteClubsResponse.java
  • src/main/java/gg/agit/konect/domain/website/repository/WebsiteQueryRepository.java
  • src/main/java/gg/agit/konect/domain/website/service/WebsiteService.java
  • src/test/java/gg/agit/konect/integration/domain/website/WebsiteApiTest.java
📜 Review details
⏰ 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). (2)
  • GitHub Check: coverage
  • GitHub Check: Analyze (java-kotlin)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.java

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.java: Java 코드에서 import로 해결할 수 있는 경우 FQCN(Full Qualified Class Name)을 사용하지 않도록 지적한다
JPA/QueryDSL 조회 변경 시 N+1, 잘못된 fetch join, count 쿼리 왜곡, pagination 깨짐, distinct 누락을 확인한다
권한 로직은 관리자 우회, 요청자와 대상자 관계, 클럽/채팅방/공지/일정의 소속 검증이 빠지지 않았는지 확인한다
soft delete, 탈퇴 사용자, 차단/제외 조건, 중복 제거가 필요한 조회에서는 응답에 노출되면 안 되는 데이터가 포함되는지 확인한다
DTO 응답 변경은 기존 클라이언트가 기대하는 필드명, nullability, enum/string 값, 정렬 순서를 깨지 않는지 확인한다
조건이 2개 이상 결합된 비즈니스 규칙, 권한 조건, soft delete 제외, 중복 제거, fallback 우선순위, 대표값 선택, DTO 변환, count 쿼리 분리, fetch join 선택 이유처럼 코드만으로 의도가 숨겨지는 지점에는 주석을 권장한다
단순 생성자 호출, 필드 매핑, 컬렉션 반환, 이름만으로 명확한 분기에는 주석을 요구하지 않는다

Files:

  • src/test/java/gg/agit/konect/integration/domain/website/WebsiteApiTest.java
  • src/main/java/gg/agit/konect/domain/website/service/WebsiteService.java
  • src/main/java/gg/agit/konect/domain/website/repository/WebsiteQueryRepository.java
  • src/main/java/gg/agit/konect/domain/website/dto/WebsiteClubsResponse.java
**/*.{sql,java}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

데이터베이스 변경에서는 마이그레이션 순서, 기존 데이터 호환성, nullable/default 처리, 롤백 난이도, 인덱스 필요성을 확인한다

Files:

  • src/test/java/gg/agit/konect/integration/domain/website/WebsiteApiTest.java
  • src/main/java/gg/agit/konect/domain/website/service/WebsiteService.java
  • src/main/java/gg/agit/konect/domain/website/repository/WebsiteQueryRepository.java
  • src/main/java/gg/agit/konect/domain/website/dto/WebsiteClubsResponse.java
**/*

⚙️ CodeRabbit configuration file

**/*: 공통 리뷰 톤 가이드:

  • 모든 코멘트는 첫 줄에 [LEVEL: ...] 태그를 포함한다.
  • 과장된 표현 없이 사실 기반으로 작성한다.
  • 한 코멘트에는 하나의 이슈만 다룬다.
  • 코드 예시가 필요하면 최소 수정 예시를 제시한다.
  • 가독성/단순화/확장성 이슈를 발견하면 우선순위를 높여 코멘트한다.

Files:

  • src/test/java/gg/agit/konect/integration/domain/website/WebsiteApiTest.java
  • src/main/java/gg/agit/konect/domain/website/service/WebsiteService.java
  • src/main/java/gg/agit/konect/domain/website/repository/WebsiteQueryRepository.java
  • src/main/java/gg/agit/konect/domain/website/dto/WebsiteClubsResponse.java
src/main/java/**/*.java

⚙️ CodeRabbit configuration file

src/main/java/**/*.java: 아래 원칙으로 리뷰 코멘트를 작성한다.

  • 코멘트는 반드시 한국어로 작성한다.
  • 반드시 수정이 필요한 항목만 코멘트로 남기고, 단순 취향 차이는 지적하지 않는다.
  • 각 코멘트 첫 줄에 심각도를 [LEVEL: high|medium|low] 형식으로 반드시 표기한다.
  • 심각도 기준: high=운영 장애 가능, medium=품질 저하, low=개선 권고.
  • 각 코멘트는 "문제 -> 영향 -> 제안" 순서로 3문장 이내로 간결하게 작성한다.
  • 가능하면 재현 조건 및 실패 시나리오도 포함한다.
  • 제안은 현재 코드베이스(Spring Boot + JPA + Flyway) 패턴과 일치해야 한다.
  • 보안, 트랜잭션 경계, 예외 처리, N+1, 성능 회귀 가능성을 우선 점검한다.
  • 가독성: 변수/메서드 이름이 의도를 바로 드러내는지, 중첩과 메서드 길이가 과도하지 않은지 점검한다.
  • 단순화: 불필요한 추상화, 중복 로직, 과한 방어 코드가 있으면 더 단순한 대안을 제시한다.
  • 확장성: 새 요구사항 추가 시 변경 범위가 최소화되는 구조인지(하드코딩 분기/값 여부 포함) 점검한다.

Files:

  • src/main/java/gg/agit/konect/domain/website/service/WebsiteService.java
  • src/main/java/gg/agit/konect/domain/website/repository/WebsiteQueryRepository.java
  • src/main/java/gg/agit/konect/domain/website/dto/WebsiteClubsResponse.java
🧠 Learnings (1)
📚 Learning: 2026-05-18T05:03:20.120Z
Learnt from: dh2906
Repo: BCSDLab/KONECT_BACK_END PR: 625
File: src/main/java/gg/agit/konect/domain/website/dto/WebsiteClubsResponse.java:0-0
Timestamp: 2026-05-18T05:03:20.120Z
Learning: 응답 DTO(또는 그 하위 클래스)의 필드에 `Schema(requiredMode = REQUIRED)`(또는 OpenAPI에서 필드를 required로 문서화)한다고 가정한 경우, 실제 런타임 계약이 비어있지 않음을 코드/DB로 보장해야 합니다. 구체적으로는 해당 값이 매핑되는 DB 컬럼이 `NOT NULL`이고(필요 시 Flyway 마이그레이션에서 기존 행 백필 후 `NOT NULL` 전환), 엔티티/필드에 `NotNull` 및 `Column(nullable = false)`(또는 동등한 검증/매핑 제약)가 선언되어 있으며, DTO/응답에서도 null이 허용되지 않도록 보장(검증/타입)하세요. 이 제약이 없는 상태에서 required로 문서화하면 리뷰 시 불일치로 플래그합니다.

Applied to files:

  • src/main/java/gg/agit/konect/domain/website/dto/WebsiteClubsResponse.java

Comment thread src/main/java/gg/agit/konect/domain/website/dto/WebsiteClubsResponse.java Outdated
@dh2906 dh2906 merged commit b22a1d5 into develop May 26, 2026
5 checks passed
@dh2906 dh2906 deleted the fix/university-club-total-count branch May 26, 2026 13:23
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