8000 [Feature] 참여율 Top 5 질문 조회 API 구현 by wngktjd13 · Pull Request #49 · If-u-Lab/If-u-server · GitHub
[go: up one dir, main page]

Skip to content

[Feature] 참여율 Top 5 질문 조회 API 구현 - #49

Merged
wngktjd13 merged 3 commits into
devfrom
feature/questions-top
Dec 26, 2025
Merged

wngktjd13 merged 3 commits into
devfrom
feature/questions-top

Conversation

@wngktjd13
Copy link
Copy Markdown
Member

🔗 Issue Link

🎯 What I Did

  • 홈 화면용 "참여율 Top 5" 질문 조회 API 구현
  • GET /api/v1/questions/top 엔드포인트 추가
  • 참여자 수(totalCount) 기준 내림차순 정렬, 상위 5개 반환

🔍 Review Points

  • QuestionRepository.findTopByParticipants: LEFT JOIN FETCH로 N+1 방지
  • QuestionService.getTopQuestions: 사용자 투표 정보 batch 조회로 N+1 방지
  • 통계 표시 로직: 기존과 동일하게 투표한 경우에만 voteStats 반환

🧪 API Test Scenarios

테스트한 엔드포인트

  • GET /api/v1/questions/top

테스트 시나리오

  1. 정상 플로우
    - 로그인 후 Top 5 질문 조회 → 참여자 수 기준 내림차순 5개 반환
    - 투표한 질문은 voteStats 포함, 미투표 질문은 voteStats null
  2. 에러 케이스
    - 미인증 요청 → 401 Unauthorized
    - CLOSED 질문이 5개 미만인 경우 → 존재하는 개수만 반환

✅ Checklist

  • Swagger 문서화 완료 (@Operation, @ApiResponse, @ApiErrorExample(s) 등)
  • 필요시 Notion 문서화 완료

@wngktjd13 wngktjd13 self-assigned this Dec 26, 2025
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @wngktjd13, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 홈 화면에 표시될 참여율이 가장 높은 상위 5개 질문을 조회하는 새로운 API를 도입합니다. 이 기능은 사용자들이 가장 인기 있는 질문들을 쉽게 발견할 수 있도록 하여 서비스의 참여도를 높이고 사용자 경험을 향상시키는 것을 목표로 합니다. 또한, 효율적인 데이터 조회를 위해 N+1 문제를 해결하는 성능 최적화가 포함되어 있습니다.

Highlights

  • 새로운 API 엔드포인트 추가: 홈 화면용 '참여율 Top 5' 질문을 조회하는 GET /api/v1/questions/top 엔드포인트가 추가되었습니다.
  • 참여자 수 기반 정렬: 새로운 API는 참여자 수(totalCount)를 기준으로 내림차순 정렬된 상위 5개의 질문을 반환합니다.
  • N+1 문제 방지 (Repository): QuestionRepository.findTopByParticipants 메서드에 LEFT JOIN FETCH를 사용하여 질문과 투표 통계 조회 시 N+1 문제를 방지했습니다.
  • N+1 문제 방지 (Service): QuestionService.getTopQuestions에서 사용자 투표 정보를 배치 조회하여 N+1 문제를 방지하고 효율성을 높였습니다.
  • 투표 통계 반환 로직: 기존 로직과 동일하게, 사용자가 투표한 질문에 대해서만 voteStats를 반환하도록 구현했습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

안녕하세요. 참여율 Top 5 질문 조회 API 구현을 위한 PR 잘 보았습니다. 전반적으로 N+1 문제를 회피하기 위해 fetch join과 batch 조회를 적절히 사용하시는 등 꼼꼼하게 구현된 것 같습니다. 코드 리뷰 중 몇 가지 개선점을 발견하여 의견을 남깁니다.

  1. QuestionRepository의 JPQL 쿼리에서 ORDER BY 절에 NULL 값 정렬 순서를 명시하여 데이터베이스 환경에 관계없이 일관된 결과를 보장하도록 수정하는 것을 제안합니다.
  2. QuestionService에서 Top 5를 의미하는 숫자 5를 상수로 추출하여 코드의 가독성과 유지보수성을 높이는 것을 권장합니다.

자세한 내용은 각 파일의 인라인 코멘트를 참고해주세요. 감사합니다.

@claude
claude Bot commented Dec 26, 2025
Copy link
Copy Markdown

PR 리뷰

좋은 점: N+1 문제 방지를 위한 LEFT JOIN FETCH와 batch 조회 적용이 잘 되어 있습니다. 기존 코드 패턴과 일관성도 유지되었습니다.

P2 (적극적으로 고려해주세요)

  • QuestionController.java:48 - Swagger 문서화가 누락되었습니다. 체크리스트에 명시된 대로 @ApiErrorExample로 에러 케이스 문서화가 필요합니다. 특히 401 Unauthorized 에러 케이스를 명시해야 합니다.
  • QuestionService.java:291 - 통계 표시 로직이 기존 getQuestions() 메서드(142-144줄)와 다릅니다. 기존은 "CLOSED이면서 투표한 경우"만 통계 표시하는데, 새 메서드는 "투표만 했으면" 표시합니다. CLOSED 상태 체크가 누락된 것으로 보입니다.

P3 (웬만하면 반영해주세요)

  • QuestionRepository.java:118-124 - JPQL의 ORDER BY가 vs.totalCount DESC만 사용하는데, totalCount가 동일한 경우 정렬 순서가 불안정합니다. ORDER BY vs.totalCount DESC, q.id DESC처럼 2차 정렬 기준 추가를 권장합니다.
  • QuestionService.java:269-304 - 단위 테스트 추가를 권장합니다. 특히 투표한 경우/안한 경우, 5개 미만인 경우 등 주요 시나리오 검증이 필요합니다.

P4 (반영해도 좋고 넘어가도 좋습니다)

  • QuestionController.java:18 - import 순서상 java.util.List가 다른 java.util imports와 분리되어 있습니다. 기존 import 그룹(20-24줄)과 통합하는 것이 일관성 있습니다.

@claude
claude Bot commented Dec 26, 2025
Copy link
Copy Markdown

PR 리뷰

참여율 Top 5 조회 API 구현이 깔끔합니다. N+1 방지를 위한 FETCH JOIN과 batch 조회가 잘 적용되었습니다.

P2 (적극적으로 고려해주세요)

  • QuestionService.java:290-294 - 기존 getQuestions() 메서드(142-146줄)와 통계 표시 로직이 불일치합니다. 기존 로직은 "CLOSED 상태이고 투표한 경우"에만 voteStats를 반환하는데, 새 메서드는 상태 체크 없이 "투표한 경우"에만 반환합니다. Top 5는 이미 CLOSED만 조회하므로 동작은 같지만, 명시적으로 상태를 체크하거나 주석으로 근거를 남기면 일관성이 좋아집니다.

P3 (웬만하면 반영해주세요)

  • QuestionRepository.java:118-123 - NULLS LAST 처리가 좋으나, voteStats가 null인 질문(투표가 전혀 없는 질문)이 Top 5에 포함될 수 있습니다. 비즈니스 요구사항에 따라 WHERE vs.totalCount > 0 조건 추가를 고려해보세요.
  • QuestionController.java:48-50 - Swagger @ApiResponse와 @ApiErrorExample 문서화가 누락되었습니다. 프로젝트 컨벤션에 따라 추가를 권장합니다.

P4 (반영해도 좋고 넘어가도 좋습니다)

  • QuestionService.java:283 - 로그 메시지가 "참여율 Top 5 조회"인데, 실제로는 "참여자 수 Top 5 조회"입니다. 용어 통일을 고려해보세요.

@wngktjd13
wngktjd13 merged commit c2c5c10 into dev Dec 26, 2025
1 check 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

0