Skip to content

Conversation

@chaen-ing
Copy link
Member

@chaen-ing chaen-ing commented Aug 31, 2025

📝 개요

3일 -> 7일로 변경

🛠️ 작업 사항

  • 작업 내용 1
  • 작업 내용 2

🔗 관련 이슈 / JIRA

✅ 체크리스트

  • 코드 리뷰 반영 완료
  • 테스트 코드 작성
  • 로컬 테스트 완료
  • 문서 업데이트 필요 시 반영

🙏 기타 사항

추가적으로 리뷰어가 알아야 할 사항 작성

Summary by CodeRabbit

  • 신기능
    • 인기 게시글 집계 기간을 최근 72시간에서 최근 7일로 확대하여 더 다양한 주간 트렌드를 반영합니다.
    • 상위 3개 게시글 선정 로직과 표시 방식은 유지되며, 노출되는 콘텐츠 범위가 넓어져 더 풍부한 추천 결과를 제공합니다.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 31, 2025

Walkthrough

인기 게시물 조회 기간을 72시간에서 7일로 변경했다. Repository의 메서드명을 7일 기준으로 수정했고, Service에서 계산 변수를 7일 기준으로 바꾸고 해당 메서드를 호출하도록 업데이트했다. 쿼리 내용과 반환 타입, 매핑 로직은 변경되지 않았다.

Changes

Cohort / File(s) Summary
Repository 메서드명 변경
src/main/java/com/kkinikong/be/community/repository/communityPost/CommunityPostRepository.java
공개 메서드명 findTop3ByLikesSince72HoursfindTop3ByLikesSince7Days로 변경. JPQL 쿼리, 파라미터, 반환 타입은 동일.
Service 기간 계산 및 호출 수정
src/main/java/com/kkinikong/be/community/service/CommunityService.java
인기 게시물 조회 기준을 72시간 → 7일로 변경. 로컬 변수명 변경(since72Hourssince7Days) 및 Repository 호출 메서드명 반영. 나머지 흐름은 동일.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Client
    participant Service as CommunityService
    participant Repo as CommunityPostRepository
    participant DB

    Client->>Service: getPopularPosts()
    Service->>Service: since = now - 7 days
    Service->>Repo: findTop3ByLikesSince7Days(since)
    Repo->>DB: JPQL 쿼리 실행 (since 기준, 좋아요 수 정렬, LIMIT 3)
    DB-->>Repo: 상위 3개 게시물
    Repo-->>Service: List<CommunityPost>
    Service-->>Client: PopularWrappingResponse
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

일주 삼일 뛰던 발, 이제는 칠일 달려요 🐇
시간의 당근 길게 늘려, 인기 글을 고르죠.
리포지토리 이름 쏙, 서비스도 척 맞추고,
좋아요 셋 꼭 집어, 바구니에 살포시.
폴짝! 주간의 빛을 안고 PR은 지나가네.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/SCRUM-350-popular-post

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
🪧 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.
    • 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.
  • 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 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/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@chaen-ing chaen-ing requested a review from erika0915 August 31, 2025 13:40
@chaen-ing chaen-ing self-assigned this Aug 31, 2025
Copy link
Contributor

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/main/java/com/kkinikong/be/community/repository/communityPost/CommunityPostRepository.java (2)

14-14: @param import이 잘못되어 바인딩이 동작하지 않습니다.

Spring Data JPA의 @Param이 아니라 Lettuce의 어노테이션을 임포트하고 있습니다. 현재 상태로는 :since 파라미터 바인딩이 실패합니다.

다음으로 교체하세요:

- import io.lettuce.core.dynamic.annotation.Param;
+ import org.springframework.data.repository.query.Param;

23-31: JPQL에서 LIMIT는 지원되지 않습니다 — 제거하고 메서드명 Top3에 맡기세요.

Hibernate JPQL에 LIMIT 3는 유효하지 않습니다. 메서드명이 findTop3...이므로 Spring Data가 자동으로 최대 3건 제한을 적용합니다. 중복/비표준 구문을 제거하세요.

   @Query(
       """
       SELECT cp FROM CommunityPost cp
       LEFT JOIN CommunityPostLike cpl ON cp.id = cpl.communityPost.id
       WHERE cpl.createdDate >= :since
       GROUP BY cp.id
       ORDER BY COUNT(cpl.id) DESC, cp.viewCount DESC
-      LIMIT 3
       """)
🧹 Nitpick comments (5)
src/main/java/com/kkinikong/be/community/repository/communityPost/CommunityPostRepository.java (3)

25-31: LEFT JOIN + WHERE 조건으로 인해 사실상 INNER JOIN으로 동작 — 의도 확인 및 ON 절로 이동 제안.

WHERE cpl.createdDate >= :since가 NULL을 제거하여 INNER JOIN과 동일하게 됩니다. 진짜 LEFT JOIN 의미(좋아요 0건인 글 포함)를 원한다면 필터를 ON 절로 옮기세요. 반대로 최소 1건 이상 좋아요가 있는 글만 원한다면 현재도 문제는 없지만 명시적으로 표현하는 편이 좋습니다.

대안 JPQL(연관 경로 사용, LIMIT 제거):

   @Query(
       """
-      SELECT cp FROM CommunityPost cp
-      LEFT JOIN CommunityPostLike cpl ON cp.id = cpl.communityPost.id
-      WHERE cpl.createdDate >= :since
+      SELECT cp FROM CommunityPost cp
+      LEFT JOIN cp.communityPostLikeList cpl ON cpl.createdDate >= :since
       GROUP BY cp.id
       ORDER BY COUNT(cpl.id) DESC, cp.viewCount DESC
       """)

32-32: 기간을 메서드명에 하드코딩하지 말고 일반화 권장.

요구사항 변경 때마다 시그니처를 바꾸지 않도록 findTop3ByLikesSince(...)처럼 범용 이름을 권장합니다. 서비스에서 기간(3일→7일→N일)은 계산해 since로 전달하세요.


25-30: 집계 성능을 위해 인덱스 확인.

CommunityPostLike(created_date, community_post_id) 또는 (community_post_id, created_date) 복합 인덱스가 없으면 7일 윈도우 스캔 비용이 큽니다. 운영 트래픽 대비 인덱스 전략을 점검하세요.

src/main/java/com/kkinikong/be/community/service/CommunityService.java (2)

166-175: 캐시 TTL/무효화 전략 재점검 필요.

메서드 파라미터가 없어 기본 키로 전역 캐시됩니다. 7일 윈도우 특성상 TTL이 너무 길면 인기글이 갱신되지 않습니다. 캐시 TTL(예: 수분~수십분)과 키 전략(카테고리별 등)을 확인하세요. unless 조건은 현재 항상 false로(비null) 사실상 효과가 없습니다.


168-168: 시간 의존 로직은 Clock 주입으로 테스트 가능하게.

LocalDateTime.now() 대신 Clock을 주입하면 경계 테스트(정확히 7일)와 타임존 이슈를 줄일 수 있습니다.

- LocalDateTime since7Days = LocalDateTime.now().minusDays(7);
+ LocalDateTime since7Days = LocalDateTime.now(clock).minusDays(7);

서비스 필드에 private final Clock clock; 추가 후 구성 예시:

// 예: @Configuration
@Bean
Clock clock() {
  return Clock.systemUTC();
}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c273ee4 and 1aea7c8.

📒 Files selected for processing (2)
  • src/main/java/com/kkinikong/be/community/repository/communityPost/CommunityPostRepository.java (1 hunks)
  • src/main/java/com/kkinikong/be/community/service/CommunityService.java (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/main/java/com/kkinikong/be/community/repository/communityPost/CommunityPostRepository.java (1)
src/main/java/com/kkinikong/be/community/domain/CommunityPost.java (1)
  • Table (26-114)
src/main/java/com/kkinikong/be/community/service/CommunityService.java (2)
src/main/java/com/kkinikong/be/community/domain/CommunityPost.java (1)
  • Table (26-114)
src/main/java/com/kkinikong/be/community/dto/response/CommunityPostPopularResponse.java (1)
  • CommunityPostPopularResponse (5-9)
🔇 Additional comments (2)
src/main/java/com/kkinikong/be/community/service/CommunityService.java (2)

168-175: 3일→7일 변경 LGTM.

윈도우 계산과 리포지토리 호출이 일관되게 업데이트되었습니다.


171-171: 레거시 메서드 호출 잔존 여부를 수동으로 최종 확인하세요.
findTop3ByLikesSince72Hourssince72Hours에 대한 검색 결과가 없으나, 스크립트만으로는 누락될 수 있어 전체 코드베이스를 직접 점검해 주세요.

@chaen-ing chaen-ing merged commit d526641 into develop Aug 31, 2025
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.

2 participants