Skip to content

[Feat] 피드 목록 페이징네이션/ 피드 탭 기본순 조회/ 피드 탭 인기순 조회/ 댓글 목록 조회#91

Merged
gkdudans merged 9 commits intodevelopfrom
feat/feed/hyun
Aug 7, 2025
Merged

[Feat] 피드 목록 페이징네이션/ 피드 탭 기본순 조회/ 피드 탭 인기순 조회/ 댓글 목록 조회#91
gkdudans merged 9 commits intodevelopfrom
feat/feed/hyun

Conversation

@doehy
Copy link
Contributor

@doehy doehy commented Aug 7, 2025

#️⃣ Issue Number

closed #90
closed #89
closed #88

📝 요약(Summary)

피드 목록 페이징네이션: 피드 목록을 한꺼번에 뿌려줬었는데 페이징네이션으로 수정

🛠️ PR 유형

어떤 변경 사항이 있나요?

  • 새로운 기능 추가
  • 버그 수정
  • CSS 등 사용자 UI 디자인 변경
  • 코드에 영향을 주지 않는 변경사항(오타 수정, 탭 사이즈 변경, 변수명 변경)
  • 코드 리팩토링
  • 주석 추가 및 수정
  • 문서 수정
  • 테스트 추가, 테스트 리팩토링
  • 빌드 부분 혹은 패키지 매니저 수정
  • 파일 혹은 폴더명 수정
  • 파일 혹은 폴더 삭제

📸스크린샷 (선택)

💬 공유사항 to 리뷰어

피드 목록 페이징네이션 리팩토링과 나머지 기능들도 구현하고 스웨거로 테스트 다 완료했습니다!

✅ PR Checklist

PR이 다음 요구 사항을 충족하는지 확인하세요.

  • 커밋 메시지 컨벤션에 맞게 작성했습니다.
  • 변경 사항에 대한 테스트를 했습니다.(버그 수정/기능에 대한 테스트).

Summary by CodeRabbit

  • 신규 기능

    • 메인 피드, 인기 피드, 피드별 댓글을 페이지네이션과 함께 조회할 수 있는 새로운 엔드포인트가 추가되었습니다.
    • 피드 요약 정보(썸네일, 좋아요/댓글 수, 작성자 프로필 이미지 등)를 제공하는 DTO가 도입되었습니다.
  • 기능 개선

    • 피드 목록 및 댓글 조회에 페이지네이션과 정렬 기능이 추가되어 더 많은 데이터를 효율적으로 탐색할 수 있습니다.
    • 피드 요약 응답에 댓글 수가 표시됩니다.
  • 버그 수정

    • 민감한 파일이 버전 관리에서 제외되었습니다.
  • 기타

    • 내부 쿼리 및 서비스 로직이 확장되어 다양한 조건의 피드 및 댓글 조회가 가능합니다.

@coderabbitai
Copy link

coderabbitai bot commented Aug 7, 2025

Warning

Rate limit exceeded

@gkdudans has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 35 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 7010314 and 885513d.

📒 Files selected for processing (2)
  • .gitignore (1 hunks)
  • src/main/java/com/example/onlyone/domain/club/service/ClubService.java (0 hunks)

Walkthrough

피드 기본 조회, 인기 조회, 댓글 목록 조회 기능이 새롭게 도입되었습니다. 이를 위해 새로운 컨트롤러와 서비스, DTO, 레포지토리 메서드가 추가 및 확장되었으며, 기존 피드 목록 조회에 페이지네이션과 정렬이 적용되었습니다. 일부 불필요한 필드가 제거되었습니다.

Changes

Cohort / File(s) Change Summary
Feed 메인 컨트롤러 및 서비스 신설
src/main/java/com/example/onlyone/domain/feed/controller/FeedMainController.java, src/main/java/com/example/onlyone/domain/feed/service/FeedMainService.java, src/main/java/com/example/onlyone/domain/feed/dto/response/FeedOverviewDto.java
피드 탭 기본/인기/댓글 목록 조회를 위한 REST 컨트롤러, 서비스, DTO 신설. 페이지네이션 및 정렬 지원, 공통 응답 구조 적용.
Feed 목록 및 댓글 조회 기능 확장
src/main/java/com/example/onlyone/domain/feed/controller/FeedController.java, src/main/java/com/example/onlyone/domain/feed/service/FeedService.java, src/main/java/com/example/onlyone/domain/feed/dto/response/FeedSummaryResponseDto.java
기존 피드 목록 조회에 페이지네이션 및 정렬 추가, 댓글 개수 필드 추가, 서비스 및 컨트롤러 메서드 시그니처 변경.
Feed/Comment 레포지토리 확장
src/main/java/com/example/onlyone/domain/feed/repository/FeedRepository.java, src/main/java/com/example/onlyone/domain/feed/repository/FeedCommentRepository.java
피드/댓글 조회를 위한 페이징, 인기순, 클럽 다중 조회 등 JPQL/Native 쿼리 메서드 추가 및 기존 단순 리스트 반환 메서드 제거.
UserClub 레포지토리 확장
src/main/java/com/example/onlyone/domain/club/repository/UserClubRepository.java
유저-클럽 관계 조회를 위한 다양한 쿼리 메서드 추가 (userId, clubIds 등으로 조회).
불필요 필드 제거
src/main/java/com/example/onlyone/domain/club/service/ClubService.java
사용하지 않는 feedRepository 필드 제거.
.gitignore
.gitignore
firebase 서비스 계정 키 파일 무시 규칙 추가.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant FeedMainController
    participant FeedMainService
    participant UserService
    participant UserClubRepository
    participant FeedRepository
    participant FeedCommentRepository

    Client->>FeedMainController: GET /feeds?page=&limit=
    FeedMainController->>FeedMainService: getPersonalFeed(pageable)
    FeedMainService->>UserService: getCurrentUser()
    FeedMainService->>UserClubRepository: findByUserUserId(userId)
    FeedMainService->>UserClubRepository: findUserIdByClubIds(clubIds)
    FeedMainService->>FeedRepository: findByClubIds(clubIds, pageable)
    FeedMainService-->>FeedMainController: List<FeedOverviewDto>
    FeedMainController-->>Client: CommonResponse.success(List<FeedOverviewDto>)

    Client->>FeedMainController: GET /feeds/popular?page=&limit=
    FeedMainController->>FeedMainService: getPopularFeed(pageable)
    FeedMainService->>FeedRepository: findPopularByClubIds(clubIds, pageable)
    FeedMainService-->>FeedMainController: List<FeedOverviewDto>
    FeedMainController-->>Client: CommonResponse.success(List<FeedOverviewDto>)

    Client->>FeedMainController: GET /feeds/{feedId}/comments?page=&limit=
    FeedMainController->>FeedMainService: getCommentList(feedId, pageable)
    FeedMainService->>FeedRepository: findByFeedId(feedId)
    FeedMainService->>FeedCommentRepository: findByFeedOrderByCreatedAtDesc(feed, pageable)
    FeedMainService-->>FeedMainController: List<FeedCommentResponseDto>
    FeedMainController-->>Client: CommonResponse.success(List<FeedCommentResponseDto>)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20분

Assessment against linked issues

Objective Addressed Explanation
피드 탭 기본 조회 Controller/Service/Repository 구현 (#88)
피드 탭 인기 조회 Controller/Service/Repository 구현 (#89)
피드 댓글 목록 조회 Controller/Service/Repository 구현 (#90)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
firebase 서비스 계정 키 파일 ignore 추가 (.gitignore) 이 변경은 보안 관점에서는 타당하지만, 피드/댓글 기능 구현과는 직접적인 관련이 없습니다.

Possibly related PRs

Suggested labels

Feed

Suggested reviewers

  • ghkddlscks19
  • NamYeonW00

Poem

🐇
피드가 쏟아져, 인기와 댓글도 척척!
토끼는 깡총깡총, 코드를 살펴보네.
페이지네이션도 척척,
새 컨트롤러는 번쩍!
오늘도 리뷰하며,
당근 한 입, 깡총!
🥕

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/feed/hyun

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

@doehy doehy requested review from ghkddlscks19 and gkdudans August 7, 2025 06:18
@doehy doehy self-assigned this Aug 7, 2025
@doehy doehy added the Feed label Aug 7, 2025
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: 6

🧹 Nitpick comments (3)
src/main/java/com/example/onlyone/domain/feed/service/FeedService.java (1)

4-4: 일부 import문의 필요성을 검토해주세요.

UserClub, UserClubRepository, FeedOverviewDto import가 이 파일에서 실제로 사용되는지 확인이 필요합니다. 사용되지 않는 import문은 제거하는 것이 좋습니다.

Also applies to: 6-6, 11-11, 26-27, 45-45

src/main/java/com/example/onlyone/domain/feed/service/FeedMainService.java (1)

116-117: 일관성 있는 repository 메서드 사용을 권장합니다.

Repository에 findByFeedId 메서드가 있음에도 findById를 사용하고 있습니다. 일관성을 위해 커스텀 메서드 사용을 고려해보세요.

src/main/java/com/example/onlyone/domain/feed/controller/FeedMainController.java (1)

5-7: 사용하지 않는 import문을 제거하세요.

FeedSummaryResponseDtoFeedService가 import되어 있지만 코드에서 사용되지 않습니다.

다음 import문들을 제거하세요:

-import com.example.onlyone.domain.feed.dto.response.FeedSummaryResponseDto;
-import com.example.onlyone.domain.feed.service.FeedService;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0649d4f and 7010314.

📒 Files selected for processing (11)
  • .gitignore (1 hunks)
  • src/main/java/com/example/onlyone/domain/club/repository/UserClubRepository.java (1 hunks)
  • src/main/java/com/example/onlyone/domain/club/service/ClubService.java (0 hunks)
  • src/main/java/com/example/onlyone/domain/feed/controller/FeedController.java (2 hunks)
  • src/main/java/com/example/onlyone/domain/feed/controller/FeedMainController.java (1 hunks)
  • src/main/java/com/example/onlyone/domain/feed/dto/response/FeedOverviewDto.java (1 hunks)
  • src/main/java/com/example/onlyone/domain/feed/dto/response/FeedSummaryResponseDto.java (1 hunks)
  • src/main/java/com/example/onlyone/domain/feed/repository/FeedCommentRepository.java (1 hunks)
  • src/main/java/com/example/onlyone/domain/feed/repository/FeedRepository.java (1 hunks)
  • src/main/java/com/example/onlyone/domain/feed/service/FeedMainService.java (1 hunks)
  • src/main/java/com/example/onlyone/domain/feed/service/FeedService.java (4 hunks)
💤 Files with no reviewable changes (1)
  • src/main/java/com/example/onlyone/domain/club/service/ClubService.java
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: in the onlyone-back project, the clubrepository search methods use list return type instea...
Learnt from: ghkddlscks19
PR: GoormOnlyOne/OnlyOne-Back#86
File: src/main/java/com/example/onlyone/domain/club/repository/ClubRepository.java:14-18
Timestamp: 2025-08-06T07:54:25.883Z
Learning: In the OnlyOne-Back project, the ClubRepository search methods use List<Object[]> return type instead of Page<Object[]> even with Pageable parameters. This is intentionally designed for infinite scrolling implementation on the frontend, where only the actual data is needed without pagination metadata.

Applied to files:

  • src/main/java/com/example/onlyone/domain/feed/service/FeedService.java
  • src/main/java/com/example/onlyone/domain/feed/repository/FeedCommentRepository.java
  • src/main/java/com/example/onlyone/domain/feed/service/FeedMainService.java
  • src/main/java/com/example/onlyone/domain/feed/controller/FeedController.java
  • src/main/java/com/example/onlyone/domain/club/repository/UserClubRepository.java
  • src/main/java/com/example/onlyone/domain/feed/repository/FeedRepository.java
📚 Learning: in the onlyone application's scheduleservice, the user has refactored the updateschedulestatus sched...
Learnt from: gkdudans
PR: GoormOnlyOne/OnlyOne-Back#53
File: src/main/java/com/example/onlyone/domain/schedule/service/ScheduleService.java:52-62
Timestamp: 2025-07-31T06:40:23.207Z
Learning: In the OnlyOne application's ScheduleService, the user has refactored the updateScheduleStatus scheduled method to use JPQL batch update instead of iterating through individual entities for better performance. They are also considering future improvements with Spring Batch or QueryDSL update functionality for more complex batch processing scenarios.

Applied to files:

  • src/main/java/com/example/onlyone/domain/feed/service/FeedService.java
  • src/main/java/com/example/onlyone/domain/club/repository/UserClubRepository.java
🔇 Additional comments (20)
src/main/java/com/example/onlyone/domain/club/repository/UserClubRepository.java (5)

7-8: 새로운 import문이 올바르게 추가되었습니다.

Query와 Param 어노테이션을 사용하는 커스텀 쿼리 메서드를 위한 적절한 import문입니다.


10-11: 컬렉션 타입 지원을 위한 import문이 적절합니다.

Collection과 List 인터페이스를 사용하는 새로운 메서드들을 위한 필요한 import문입니다.


19-19: 표준 Spring Data JPA 네이밍 규칙을 잘 따릅니다.

findByUserUserId 메서드는 User 엔티티의 userId 필드를 통한 조회를 명확하게 표현합니다.


21-22: JPQL 쿼리가 올바르게 구현되었습니다.

DISTINCT를 사용하여 중복 제거하고, IN 절로 여러 클럽 ID를 처리하는 효율적인 쿼리입니다. 파라미터 바인딩도 적절합니다.


24-24: 컬렉션 기반 조회 메서드가 적절합니다.

findByUserUserIdIn 메서드는 여러 사용자 ID를 한 번에 조회할 수 있는 효율적인 방법을 제공합니다.

src/main/java/com/example/onlyone/domain/feed/dto/response/FeedSummaryResponseDto.java (1)

16-16: 댓글 수 필드가 적절히 추가되었습니다.

commentCount 필드가 기존 likeCount 필드와 일관된 네이밍과 타입으로 추가되어 피드 요약 정보를 보완합니다.

src/main/java/com/example/onlyone/domain/feed/repository/FeedCommentRepository.java (2)

3-3: 필요한 import문들이 적절히 추가되었습니다.

새로운 메서드 시그니처를 지원하기 위한 Feed, Pageable, List 타입 import가 올바르게 추가되었습니다.

Also applies to: 5-5, 8-8


11-11: 페이지네이션을 지원하는 댓글 조회 메서드가 적절합니다.

findByFeedOrderByCreatedAtDesc 메서드는 최신 댓글을 우선 표시하는 적절한 정렬 순서를 가지고 있습니다. 프로젝트의 무한 스크롤 패턴에 맞게 List<FeedComment>를 반환하는 것도 일관성이 있습니다.

src/main/java/com/example/onlyone/domain/feed/service/FeedService.java (1)

91-91: FeedRepository.findByClub 메서드 존재 및 정렬 옵션 확인

FeedRepository 인터페이스에

Page<Feed> findByClub(Club club, Pageable pageable);

가 정의되어 있어 호출은 정상입니다.
다만, 기존 findAllByClubOrderByCreatedAtDesccreatedAt 기준 내림차순 정렬이 메서드명으로 고정되어 있던 반면, findByClub은 Pageable에 지정된 Sort 옵션에 따라 결과가 달라집니다.

아래 위치에서 Pageable 생성 시 Sort.by("createdAt").descending()이 포함되어 있는지 확인해주세요.

  • src/main/java/com/example/onlyone/domain/feed/service/FeedService.java (91행):
    feedRepository.findByClub(club, pageable)
  • Pageable을 생성하는 컨트롤러(또는 호출부) 코드
src/main/java/com/example/onlyone/domain/feed/controller/FeedController.java (3)

13-16: 페이지네이션 관련 import문이 적절히 추가되었습니다.

Page, PageRequest, Pageable, Sort 클래스들이 새로운 페이지네이션 기능을 위해 올바르게 import되었습니다.


48-50: 페이지네이션 파라미터 설정이 적절합니다.

기본값(page=0, limit=20)이 합리적이고, 파라미터명도 직관적입니다. RequestParam 설정이 올바릅니다.


51-52: 정렬 조건이 적절하게 설정되었습니다.

최신 피드를 우선 표시하는 createdAt 내림차순 정렬이 피드 목록 조회에 적합합니다.

그러나 서비스 레이어의 반환 타입과 프로젝트 패턴의 일관성을 확인해주세요. 프로젝트에서 무한 스크롤을 위해 List 타입을 선호한다면 이 부분도 고려가 필요할 수 있습니다.

src/main/java/com/example/onlyone/domain/feed/dto/response/FeedOverviewDto.java (1)

9-20: DTO 클래스 구현이 적절합니다.

Lombok 어노테이션 사용과 필드 타입 선택이 적절하며, 피드 개요 정보를 표현하는 데 필요한 모든 필드가 포함되어 있습니다.

src/main/java/com/example/onlyone/domain/feed/repository/FeedRepository.java (3)

17-19: 페이지네이션 지원 메서드들이 잘 구현되었습니다.

Page<Feed>Feed 단건 조회 메서드가 적절히 추가되어 페이지네이션 요구사항을 충족합니다.


21-22: JPQL 쿼리 구현이 적절합니다.

여러 클럽 ID로 피드를 조회하는 JPQL 쿼리가 올바르게 작성되었습니다.


24-42: 인기도 계산 로직 비즈니스 검증 필요

네이티브 쿼리에서 다음 요소들이 비즈니스 요구사항에 부합하는지 확인 부탁드립니다.

  • 좋아요 수 + (댓글 수 × 2)에 로그 함수(LOG·GREATEST) 적용
  • 시간 경과에 따른 점수 감소 계수: TIMESTAMPDIFF(HOUR, f.created_at, NOW()) / 12.0
  • 수동 LIMIT 절(:#{#pageable.offset}, :#{#pageable.pageSize}) 사용 방식

호출 위치 검토 결과:

  • src/main/java/com/example/onlyone/domain/feed/repository/FeedRepository.java: findPopularByClubIds 네이티브 쿼리 정의
  • src/main/java/com/example/onlyone/domain/feed/service/FeedMainService.java: findPopularByClubIds(allClubIds, pageable)로 단일 호출

추가 검토 제안:

  • 12시간 단위 감소 계수(12.0)의 산정 근거와 요구사항 문서화 여부
  • 서브쿼리(좋아요/댓글 집계) 성능 최적화 방안
  • Spring Data Pageable과의 연동이 의도대로 동작하는지 확인

위 사항들을 비즈니스 담당자 혹은 도메인 전문가와 함께 검증해주세요.

src/main/java/com/example/onlyone/domain/feed/service/FeedMainService.java (1)

45-62: 비즈니스 로직 구현이 적절합니다.

사용자의 클럽과 친구들의 클럽을 찾아서 전체 피드를 조회하는 로직이 잘 구현되어 있습니다. 특히 라인 57의 필터링 로직으로 중복을 제거하는 것이 좋습니다.

src/main/java/com/example/onlyone/domain/feed/controller/FeedMainController.java (3)

30-39: REST API 엔드포인트 구현이 잘되어 있습니다.

  • 적절한 HTTP 상태 코드 사용
  • 페이지네이션 파라미터 기본값 설정
  • Swagger 문서화
  • 일관된 응답 래핑

API 설계가 RESTful 원칙을 잘 따르고 있습니다.

Also applies to: 52-60


41-50: 인기순 피드 엔드포인트가 적절히 구현되었습니다.

Sort.unsorted() 사용이 올바릅니다. 인기도 정렬은 네이티브 쿼리에서 처리되므로 추가 정렬이 불필요합니다.


36-36: 정렬 주입이 정상적으로 동작합니다 – 추가 조치 불필요

Spring Data JPA는 JPQL(@query) 메서드에 static ORDER BY가 정의되어 있지 않을 경우, Pageable 파라미터의 Sort 설정을 자동으로 주입합니다.

  • findByClubIds는 nativeQuery가 아닌 JPQL(@query)이며, 쿼리에 ORDER BY가 없으므로
  • 컨트롤러의 Sort.by(DESC, "createdAt")가 정상 적용되어 결과가 생성일자 내림차순으로 정렬됩니다.

위 리뷰는 해당 동작 방식을 오해한 것으로 보이므로 무시하시면 됩니다.

Likely an incorrect or invalid review comment.

gkdudans
gkdudans previously approved these changes Aug 7, 2025
Copy link
Contributor

@gkdudans gkdudans left a comment

Choose a reason for hiding this comment

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

수고하셨습니당~~ 👍 👍 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] 댓글 목록 조회 [feat] 피드 탭 인기 조회 [Feat] 피드 탭 기본 조회

2 participants