Skip to content

Conversation

@whqtker
Copy link
Member

@whqtker whqtker commented Aug 9, 2025

관련 이슈

작업 내용

전체 게시글 조회 시 첨부된 이미지들 중 첫 번째 이미지를 가져오는 로직은 이미 구현되어 있었습니다.
다만 응답에서 변수명이 url 로 작성되었고, 혼동의 여지가 있기 때문에, postThumbnailUrl 로 변수명을 변경하였습니다.

또한 첫 번째 이미지를 가져오는지 확인하는 테스트 코드를 추가로 작성하였습니다.

이 PR이 머지되면 bruno PR 또한 올리겠습니다 !

특이 사항

리뷰 요구사항 (선택)

@whqtker whqtker self-assigned this Aug 9, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 9, 2025

Walkthrough

  1. PostListResponse 레코드 필드명 변경. 레코드의 필드명이 기존 url에서 postThumbnailUrl로 변경되었습니다.
  2. 게시글 썸네일 반환 테스트 추가 — 첫번째 이미지. PostQueryServiceTest에 게시글 목록 조회 시 첫 번째 이미지를 썸네일로 반환하는 테스트가 추가되었습니다.
  3. 게시글 썸네일 반환 테스트 추가 — 이미지 없음. PostQueryServiceTest에 게시글에 이미지가 없을 때 썸네일로 null을 반환하는 테스트가 추가되었습니다.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a4a4cd8 and 0ee3050.

📒 Files selected for processing (1)
  • src/test/java/com/example/solidconnection/community/post/service/PostQueryServiceTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/com/example/solidconnection/community/post/service/PostQueryServiceTest.java
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • 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 (4)
src/main/java/com/example/solidconnection/community/post/dto/PostListResponse.java (2)

18-18: 2) API 응답 필드명 변경에 따른 호환성 확인 요청

  • 이 변경은 외부 응답 스키마를 바꾸므로, 기존 클라이언트가 url을 기대한다면 깨질 수 있습니다.
  • 브레이킹 체인지가 의도된 것인지 확인해 주세요. 그리고 API 문서/브루노 스위트/프런트 코드 동시 반영을 권장합니다.
  • 컨트랙트 테스트(예: MockMvc + JSONPath)로 postThumbnailUrl 필드 노출을 검증하면 회귀를 막을 수 있습니다.

18-18: 3) null 필드 응답 정책 정리 제안

  • 이미지가 없을 때 null을 반환합니다. API 응답에서 null 필드를 숨기고 싶다면 Jackson 설정을 통해 간단히 제어할 수 있습니다.
  • 레코드에 다음 어노테이션을 적용하면 응답에서 null 필드를 제거할 수 있습니다.
// import com.fasterxml.jackson.annotation.JsonInclude;
@JsonInclude(JsonInclude.Include.NON_NULL)
public record PostListResponse(...) { ... }
src/test/java/com/example/solidconnection/community/post/service/PostQueryServiceTest.java (2)

175-177: 2) ‘첫 번째’의 정의를 명확히 하여 테스트 플래키니스 방지

  • getFirstImageUrl(post)는 컬렉션의 순서에 의존합니다. 컬렉션이 List(삽입 순서 보장)인지, JPA에서 @OrderBy로 정렬이 보장되는지 확인이 필요합니다.
  • 보장이 없다면 아래 중 하나로 결정성을 확보해 주세요.
    • 엔티티 컬렉션에 @OrderBy("createdAt asc") 또는 @OrderBy("id asc") 추가.
    • 조회 쿼리에서 ORDER BY로 정렬.
    • 코드에서 sorted(Comparator.comparing(PostImage::getId))findFirst() 적용.
// 예시: 코드에서 결정적 정렬 보장
return post.getPostImageList().stream()
        .sorted(Comparator.comparing(PostImage::getId)) // 혹은 createdAt
        .map(PostImage::getUrl)
        .findFirst()
        .orElse(null);

179-199: 3) 직렬화 스키마 검증 테스트(컨트롤러 레벨) 추가 제안

  • 본 테스트는 서비스 레이어 객체를 검증합니다. 실제 HTTP 응답에서 JSON 필드명이 postThumbnailUrl로 노출되는지까지 확인하면 더 견고해집니다.
  • MVC 슬라이스 테스트(WebMvcTest)로 목록 API를 호출하고 jsonPath("$[?(@.id==%s)].postThumbnailUrl") 형태로 필드 존재/값을 검증하는 테스트를 추가하는 것을 권장합니다.
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3f4a24a and a4a4cd8.

📒 Files selected for processing (2)
  • src/main/java/com/example/solidconnection/community/post/dto/PostListResponse.java (1 hunks)
  • src/test/java/com/example/solidconnection/community/post/service/PostQueryServiceTest.java (1 hunks)
⏰ 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). (1)
  • GitHub Check: build
🔇 Additional comments (2)
src/main/java/com/example/solidconnection/community/post/dto/PostListResponse.java (1)

18-18: 1) DTO 필드명 변경: postThumbnailUrl로 명확성 향상

의도가 분명해져 가독성이 좋아졌습니다. 네이밍 일관성 면에서도 👍입니다.

src/test/java/com/example/solidconnection/community/post/service/PostQueryServiceTest.java (1)

170-199: 1) 첫 번째 이미지 썸네일 검증 테스트 추가: 의도를 정확히 커버

  • 두 장의 이미지를 추가하고, 첫 번째 URL을 썸네일로 검증하는 핵심 시나리오를 잘 담았습니다.
  • 이미지가 없는 게시글에 대해 null을 검증한 점도 좋아요.

Copy link
Contributor

@Gyuhyeok99 Gyuhyeok99 left a comment

Choose a reason for hiding this comment

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

확인했습니다!

Comment on lines 15 to +18
ZonedDateTime createdAt,
ZonedDateTime updatedAt,
String postCategory,
String url
String postThumbnailUrl
Copy link
Contributor

Choose a reason for hiding this comment

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

이 pr과 관련은 없지만 불필요한 Long타입 나중에 한 번 싹 고치는 pr 제가 올리겠습니다!

Copy link
Collaborator

@nayonsoso nayonsoso left a comment

Choose a reason for hiding this comment

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

이 PR이 머지되면 bruno PR 또한 올리겠습니다 !

꼼꼼한 체크 감사드립니다🙇🏻‍♀️

Comment on lines 184 to 198
// then
PostListResponse post1Response = actualResponses.stream()
.filter(p -> p.id().equals(post1.getId()))
.findFirst()
.orElseThrow();

PostListResponse post3Response = actualResponses.stream()
.filter(p -> p.id().equals(post3.getId()))
.findFirst()
.orElseThrow();

assertAll(
() -> assertThat(post1Response.postThumbnailUrl()).isEqualTo(firstImageUrl),
() -> assertThat(post3Response.postThumbnailUrl()).isNull()
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

조금 사소한 부분일수도 있는데요..!

지금의 테스트는 두가지 동작을 테스트하고 있는 것 같아요.

  1. 게시글에 여러개의 이미지가 있으면 첫번째 이미지 썸네일을 반환한다.
  2. 게시글에 이미지가 없다면, 썸네일을 null로 반환한다.

이 두가지를 각각의 테스트로 나누어 "테스트가 한가지만 검증하도록" 하는 것도 좋을 것 같습니다~
하지만 치명적인 부분은 아니라 생각해서 approve 드립니다! ☺️

Copy link
Member Author

Choose a reason for hiding this comment

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

아핫 그러네요 저도 분리하는 것이 더 적합하다고 생각합니다 !!

0ee3050

@whqtker whqtker merged commit 51d1d06 into solid-connection:develop Aug 11, 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.

chore: 커뮤니티 탭에서 첫 번째 사진을 보여주도록

3 participants