Skip to content

Conversation

@Nuung
Copy link
Member

@Nuung Nuung commented Apr 19, 2025

🔥 변경 사항

  • 배치에서 soft delete 기능이 작동하도록 변경했습니다.
  • 그에 따라 api 쪽에서 post 와 관련된 모든 질의를 is_active 가 True 인 것만 가져오게 업데이트 했습니다.
  • 그리고 그에 따라 test code 역시 업데이트 했습니다.

🏷 관련 이슈

  • 없습니다!

📸 스크린샷 (UI 변경 시 필수)

  • ui 와 관련된 내용이 아니며, 노션을 꼭 참조해 주세요!

📌 체크리스트

  • 기능이 정상적으로 동작하는지 테스트 완료
  • 코드 스타일 가이드 준수 여부 확인
  • 관련 문서 업데이트 완료 (필요 시)

Summary by CodeRabbit

  • 버그 수정

    • 모든 게시글 관련 조회에서 비활성화된 게시글이 제외되어, 이제 활성화된 게시글만 조회됩니다.
  • 테스트

    • 게시글 조회 시 활성 상태 조건이 올바르게 적용되는지 확인하는 테스트가 추가되었습니다.
    • 테스트 코드가 리팩토링되어 중복된 모킹이 줄어들고, 테스트 실행 전 모킹이 초기화됩니다.
@Nuung Nuung added the enhancement New feature or request label Apr 19, 2025
@Nuung Nuung self-assigned this Apr 19, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 19, 2025

"""

Walkthrough

이번 변경에서는 PostRepository 클래스의 여러 SQL 쿼리에 is_active = TRUE 조건이 추가되어, 활성화된 게시글만 조회하도록 쿼리가 수정되었습니다. 이에 맞춰 테스트 코드에도 각 메서드가 해당 필터를 쿼리에 포함하는지 검증하는 테스트 케이스가 추가되었고, 중복된 목(mock) 객체 생성을 줄이기 위해 헬퍼 함수가 도입되었습니다. 기존의 로직, 제어 흐름, 에러 처리, 공개 API에는 변동이 없습니다.

Changes

파일/경로 변경 요약
src/repositories/post.repository.ts 여러 메서드의 SQL 쿼리에 p.is_active = TRUE 조건 추가. 활성 게시글만 조회하도록 쿼리 수정.
src/repositories/test/post.repo.test.ts 각 메서드 쿼리에 is_active = TRUE 조건 포함 여부를 검증하는 테스트 케이스 추가. jest.clearAllMocks() 추가 및 목 객체 생성 헬퍼 함수 도입.

Poem

🐰
활성 게시글만 쏙쏙 골라
쿼리 속에 TRUE를 담아
테스트 토끼도 깡총깡총
조건 확인, 실수는 NO!
오늘도 데이터는 반짝반짝
코드와 테스트, 모두 굿잡!
🌱
"""


📜 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 0cb309f and 03525a0.

📒 Files selected for processing (1)
  • src/repositories/__test__/post.repo.test.ts (11 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/repositories/test/post.repo.test.ts

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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
Member

@six-standard six-standard left a comment

Choose a reason for hiding this comment

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

코드 잘 읽었습니다!
is_active 속성만 추가된 수준이라 당장은 크게 리뷰할 부분이 없는 것 같네요;;

@Nuung
Copy link
Member Author

Nuung commented Apr 21, 2025

코드 잘 읽었습니다! is_active 속성만 추가된 수준이라 당장은 크게 리뷰할 부분이 없는 것 같네요;;

혹시나 제가 빼먹은 테스트 케이스, 엣지 케이스를 봐주면 너무 좋을 것 같아요!

@six-standard
Copy link
Member

코드 잘 읽었습니다! is_active 속성만 추가된 수준이라 당장은 크게 리뷰할 부분이 없는 것 같네요;;

혹시나 제가 빼먹은 테스트 케이스, 엣지 케이스를 봐주면 너무 좋을 것 같아요!

이전부터 큰 문제 아니면 사소한 오타 정도를 계속 보고 있었어서, 그 부분을 놓친 것 같네요.
여유있을 때 다시 한 번 확인해보겠습니다~

Copy link
Contributor

@ooheunda ooheunda left a comment

Choose a reason for hiding this comment

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

코드 잘 봤습니다! 기준님 말씀대로 변경사항이 복잡하지 않아서 크게 문제될 부분은 없어 보입니다.
일단 Approve 하고 테스트 케이스 생각나면 추가로 말씀 드릴게요!

좋았던 점

  • 간단한 테스트긴 하지만 테스트 케이스 설명이 명확하고 구조가 깔끔해서 가독성이 좋았습니다!

궁금한 점

mockPool.query.mockResolvedValue에 들어가는 값 중 rows, rowCount를 제외한 나머지 필드는 테스트에서 의미가 있는 값은 아닌 것 같은데 다 작성하신 이유가 있을까요?

 mockPool.query.mockResolvedValue({ rows: mockPosts, rowCount: mockPosts.length, command: '', oid: 0, fields: [], } as QueryResult);

QueryResult 타입을 맞추시기 위함 같기도 한데, Partial<QueryResult>로 우회하는 방법을 쓰면 명시성이 떨어질까요?
as를 사용해서 그런지 Partial을 쓰지 않고 command, oid, fields를 삭제해도 타입 에러가 뜨진 않네요.

@Nuung
Copy link
Member Author

Nuung commented Apr 21, 2025

코드 잘 봤습니다! 기준님 말씀대로 변경사항이 복잡하지 않아서 크게 문제될 부분은 없어 보입니다. 일단 Approve 하고 테스트 케이스 생각나면 추가로 말씀 드릴게요!

좋았던 점

  • 간단한 테스트긴 하지만 테스트 케이스 설명이 명확하고 구조가 깔끔해서 가독성이 좋았습니다!

궁금한 점

mockPool.query.mockResolvedValue에 들어가는 값 중 rows, rowCount를 제외한 나머지 필드는 테스트에서 의미가 있는 값은 아닌 것 같은데 다 작성하신 이유가 있을까요?

 mockPool.query.mockResolvedValue({ rows: mockPosts, rowCount: mockPosts.length, command: '', oid: 0, fields: [], } as QueryResult);

QueryResult 타입을 맞추시기 위함 같기도 한데, Partial<QueryResult>로 우회하는 방법을 쓰면 명시성이 떨어질까요? as를 사용해서 그런지 Partial을 쓰지 않고 command, oid, fields를 삭제해도 타입 에러가 뜨진 않네요.

  1. 실제 psql 라이브러리 활용해 result를 받아오면 QueryResult 로 디시리얼라이징 (byte to object) 되어서 최대한 그 형태를 맞추고 싶어서 였습니다.
  2. Partial<QueryResult> 정말 좋은 제안인데요! 사실 태초에 테스트 코드 짤때 저렇게 하나 목킹해두고 tpye 형태로 재활용 하려고 했는데 복붙하다 이렇게까지 된 듯 하네요 ㅎㅎ :) 리펙토링 해볼게요! 🙏🔥🔥🫡🫡
Copy link
Contributor

@Jihyun3478 Jihyun3478 left a comment

Choose a reason for hiding this comment

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

좋았던 점

  • 전체적으로 createMockQueryResult()로 mock 처리가 잘 되어있어서 코드 일관성이 좋았던 것 같습니다!

PS. 부족한 테스트케이스 또는 엣지케이스는 현재까지 안 보이는 것 같습니다! 한 번 더 살펴보겠습니다~!!

@Nuung Nuung merged commit 62a2b6b into main Apr 24, 2025
5 checks passed
@Nuung Nuung deleted the feature/batch-post-soft-delete branch April 24, 2025 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

5 participants