Skip to content

[hotfix] 전체 팔로잉/팔로워 count 반환 및 isFollowing = true 반환#149

Merged
buzz0331 merged 1 commit intodevelopfrom
fix/#148-following-return
Aug 5, 2025
Merged

[hotfix] 전체 팔로잉/팔로워 count 반환 및 isFollowing = true 반환#149
buzz0331 merged 1 commit intodevelopfrom
fix/#148-following-return

Conversation

@buzz0331
Copy link
Contributor

@buzz0331 buzz0331 commented Aug 5, 2025

#️⃣ 연관된 이슈

closes #148

📝 작업 내용

@heeeeyong 님의 요청에 따라 특정 사용자의 팔로워 조회, 내 팔로잉 조회 api 시에 전체 팔로잉/팔로워 count를 반환하고 내 팔로잉 조회시에는 isFollowing을 true로 반환합니다.

📸 스크린샷

💬 리뷰 요구사항

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

📌 PR 진행 시 이러한 점들을 참고해 주세요

* P1 : 꼭 반영해 주세요 (Request Changes) - 이슈가 발생하거나 취약점이 발견되는 케이스 등
* P2 : 반영을 적극적으로 고려해 주시면 좋을 것 같아요 (Comment)
* P3 : 이런 방법도 있을 것 같아요~ 등의 사소한 의견입니다 (Chore)

Summary by CodeRabbit

  • 신규 기능

    • 팔로워 목록과 팔로잉 목록 응답에 전체 팔로워 수 및 전체 팔로잉 수가 표시됩니다.
    • 팔로잉 목록 내 각 사용자에 대해 현재 사용자가 팔로우 중인지 여부가 추가로 표시됩니다.
  • 기타

    • 일부 기존 기능이 더 이상 권장되지 않음을 명시하는 안내가 추가되었습니다.

@buzz0331 buzz0331 requested a review from seongjunnoh August 5, 2025 17:06
@buzz0331 buzz0331 self-assigned this Aug 5, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 5, 2025

Walkthrough

팔로워 및 팔로잉 목록 조회 API의 응답에 전체 팔로워/팔로잉 개수를 포함하도록 관련 DTO와 서비스 로직이 확장되었습니다. 또한, 팔로잉 여부 확인 메서드에 @Deprecated 어노테이션이 추가되었고, 팔로잉 관련 JPA 쿼리 및 매퍼에 필드가 보강되었습니다.

Changes

Cohort / File(s) Change Summary
팔로워/팔로잉 응답 DTO 확장
src/main/java/konkuk/thip/user/adapter/in/web/response/UserFollowersResponse.java, src/main/java/konkuk/thip/user/adapter/in/web/response/UserFollowingResponse.java
팔로워/팔로잉 목록 응답에 각각 totalFollowerCount, totalFollowingCount 필드 추가, 팔로잉 DTO에 isFollowing 필드 추가
팔로잉 쿼리 및 저장소 메서드 추가/변경
src/main/java/konkuk/thip/user/adapter/out/persistence/FollowingQueryPersistenceAdapter.java, src/main/java/konkuk/thip/user/adapter/out/persistence/repository/following/FollowingJpaRepository.java, src/main/java/konkuk/thip/user/application/port/out/FollowingQueryPort.java
전체 팔로잉 수 반환 메서드 추가, 팔로잉 여부 확인 쿼리 메서드 JPQL로 변경 및 네이밍 단순화
서비스 로직 응답 개선
src/main/java/konkuk/thip/user/application/service/following/UserGetFollowService.java
팔로워/팔로잉 목록 조회 시 전체 개수 포함되도록 응답 빌더 수정
매퍼 어노테이션 추가
src/main/java/konkuk/thip/user/application/mapper/FollowQueryMapper.java
toFollowingDto 매핑 시 isFollowing 필드 true로 설정하는 매핑 어노테이션 추가
API 메서드 Deprecated 처리
src/main/java/konkuk/thip/user/adapter/in/web/UserQueryController.java
checkIsFollowing 메서드에 @Deprecated 어노테이션 추가

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant UserGetFollowService
    participant FollowingQueryPort
    participant User (도메인)
    participant ResponseDTO

    Client->>UserGetFollowService: getUserFollowers(userId, ...)
    UserGetFollowService->>User (도메인): getFollowerCount()
    UserGetFollowService->>ResponseDTO: UserFollowersResponse(..., totalFollowerCount)
    UserGetFollowService-->>Client: 응답 반환

    Client->>UserGetFollowService: getMyFollowing(userId, ...)
    UserGetFollowService->>FollowingQueryPort: getFollowingCountByUser(userId)
    UserGetFollowService->>ResponseDTO: UserFollowingResponse(..., totalFollowingCount)
    UserGetFollowService-->>Client: 응답 반환
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

Objective Addressed Explanation
팔로잉/팔로워 목록 조회시 전체 개수 반환 (#148)

Assessment against linked issues: Out-of-scope changes

(해당 사항 없음)

Possibly related PRs

Suggested labels

⚡️ fix, 🛠️ feat

Suggested reviewers

  • hd0rable
  • seongjunnoh

Poem

🐇
팔로워 수를 세어보니
숫자가 한눈에 쏙!
팔로잉도 함께 담아
토끼 귀가 쫑긋쫑긋
Deprecated 메서드엔
안녕 인사 남기고
서버는 더 똑똑해졌죠!
🥕✨

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 fix/#148-following-return

🪧 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

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/konkuk/thip/user/adapter/in/web/UserQueryController.java (1)

102-102: @deprecated 어노테이션에 추가 정보가 필요합니다.

메서드를 deprecated로 표시했지만, 대체 방법이나 제거 예정 버전에 대한 정보가 없습니다. 개발자들이 마이그레이션할 수 있도록 더 구체적인 정보를 제공하는 것이 좋겠습니다.

다음과 같이 수정하는 것을 권장합니다:

-    @Deprecated
+    @Deprecated(since = "version", forRemoval = true)

또는 Javadoc에서 대체 방법을 명시하세요.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6974573 and 3ee7fc1.

📒 Files selected for processing (8)
  • src/main/java/konkuk/thip/user/adapter/in/web/UserQueryController.java (1 hunks)
  • src/main/java/konkuk/thip/user/adapter/in/web/response/UserFollowersResponse.java (1 hunks)
  • src/main/java/konkuk/thip/user/adapter/in/web/response/UserFollowingResponse.java (2 hunks)
  • src/main/java/konkuk/thip/user/adapter/out/persistence/FollowingQueryPersistenceAdapter.java (1 hunks)
  • src/main/java/konkuk/thip/user/adapter/out/persistence/repository/following/FollowingJpaRepository.java (1 hunks)
  • src/main/java/konkuk/thip/user/application/mapper/FollowQueryMapper.java (1 hunks)
  • src/main/java/konkuk/thip/user/application/port/out/FollowingQueryPort.java (1 hunks)
  • src/main/java/konkuk/thip/user/application/service/following/UserGetFollowService.java (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: thip 프로젝트에서는 cqrs port 분리 시 다음 컨벤션을 따름: commandport에는 findbyxxx를 통해 도메인 엔티티를 찾아오는 메서드를 추가하고, querypo...
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#43
File: src/main/java/konkuk/thip/book/application/port/out/BookCommandPort.java:0-0
Timestamp: 2025-07-03T03:05:05.031Z
Learning: THIP 프로젝트에서는 CQRS Port 분리 시 다음 컨벤션을 따름: CommandPort에는 findByXXX를 통해 도메인 엔티티를 찾아오는 메서드를 추가하고, QueryPort에는 조회 API의 response에 해당하는 데이터들을 DB로부터 조회하는 메서드를 추가함.

Applied to files:

  • src/main/java/konkuk/thip/user/application/port/out/FollowingQueryPort.java
📚 Learning: spring data jpa에서 findby{fieldname} 패턴의 메서드는 명시적 선언 없이 자동으로 생성되며, optional 반환 타입을 사용하는 것이 nu...
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#36
File: src/main/java/konkuk/thip/user/adapter/out/persistence/UserJpaRepository.java:7-7
Timestamp: 2025-06-29T09:47:31.299Z
Learning: Spring Data JPA에서 findBy{FieldName} 패턴의 메서드는 명시적 선언 없이 자동으로 생성되며, Optional<Entity> 반환 타입을 사용하는 것이 null 안전성을 위해 권장됩니다.

Applied to files:

  • src/main/java/konkuk/thip/user/adapter/out/persistence/repository/following/FollowingJpaRepository.java
🔇 Additional comments (13)
src/main/java/konkuk/thip/user/application/port/out/FollowingQueryPort.java (1)

16-16: 새로운 메서드 추가가 적절합니다.

getFollowingCountByUser 메서드가 QueryPort 인터페이스에 올바르게 추가되었습니다. CQRS 패턴에 따른 조회 API 응답 데이터 조회 메서드로서 적절한 위치와 시그니처를 가지고 있습니다.

src/main/java/konkuk/thip/user/adapter/in/web/response/UserFollowersResponse.java (1)

10-10: 총 팔로워 수 필드 추가가 적절합니다.

totalFollowerCount 필드 추가로 팔로워 목록 조회 API 응답에 전체 개수 정보를 포함할 수 있게 되었습니다. PR 목표에 부합하는 변경사항입니다.

src/main/java/konkuk/thip/user/application/mapper/FollowQueryMapper.java (2)

7-7: MapStruct import 추가가 적절합니다.

새로운 매핑 어노테이션 사용을 위한 import 추가입니다.


14-14: isFollowing 필드 매핑이 올바릅니다.

인증된 사용자의 팔로잉 목록 조회 시 isFollowing을 항상 true로 설정하는 것이 논리적으로 맞습니다. PR 목표에 부합하는 구현입니다.

src/main/java/konkuk/thip/user/adapter/out/persistence/FollowingQueryPersistenceAdapter.java (2)

51-51: Repository 메서드 호출 간소화가 적절합니다.

새로운 JPQL 기반 메서드 existsByUserIdAndFollowingUserId 사용으로 코드가 더 간결해졌습니다.


54-57: 새로운 팔로잉 수 조회 메서드 구현이 올바릅니다.

FollowingQueryPort 인터페이스의 새로운 메서드를 적절히 구현했습니다. Repository 계층의 카운트 메서드를 올바르게 호출하고 있습니다.

src/main/java/konkuk/thip/user/adapter/in/web/response/UserFollowingResponse.java (2)

10-10: 새로운 totalFollowingCount 필드 추가 확인됨

전체 팔로잉 개수를 반환하기 위한 필드가 올바르게 추가되었습니다. Integer 타입 사용이 적절합니다.


21-21: isFollowing 필드 추가 확인됨

FollowingDto에 isFollowing 불린 필드가 올바르게 추가되었습니다. 인증된 사용자의 팔로잉 목록 조회 시 true를 반환하는 요구사항과 일치합니다.

src/main/java/konkuk/thip/user/application/service/following/UserGetFollowService.java (3)

42-42: 팔로워 개수 반환 로직 확인됨

기존 User 엔티티의 followerCount 필드를 활용하여 효율적으로 총 팔로워 수를 반환하고 있습니다.


52-52: 팔로잉 개수 조회를 위한 추가 쿼리 도입

총 팔로잉 개수를 정확히 조회하기 위해 새로운 포트 메서드를 호출합니다. 추가 쿼리가 발생하지만 hotfix 요구사항을 충족하기 위해 필요한 변경입니다.

성능 최적화를 위해 향후 User 엔티티에 followingCount 필드 추가를 고려해보세요.


64-64: 응답 빌딩에 총 팔로잉 개수 포함 확인됨

조회된 totalFollowingCount가 응답 객체에 올바르게 포함되었습니다.

src/main/java/konkuk/thip/user/adapter/out/persistence/repository/following/FollowingJpaRepository.java (2)

11-12: 팔로잉 존재 여부 확인을 위한 JPQL 쿼리 메서드 추가

COUNT(f) > 0 패턴을 사용한 존재 여부 확인 로직이 올바르게 구현되었습니다. 엔티티 관계를 통한 조인 경로도 적절합니다.


14-15: 팔로잉 개수 조회를 위한 JPQL 쿼리 메서드 추가

사용자별 총 팔로잉 개수를 조회하는 간단하고 명확한 COUNT 쿼리입니다. 반환 타입 int도 적절합니다.

@buzz0331 buzz0331 merged commit 288fd54 into develop Aug 5, 2025
2 checks passed
@buzz0331 buzz0331 deleted the fix/#148-following-return branch August 5, 2025 17:09
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.

[THIP2025-211] [hotfix] 팔로잉 / 팔로워 목록 조회시 전체 개수 반환

1 participant