Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 페이지네이션 목록 조회 구현 #113

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

printSANO
Copy link
Member

@printSANO printSANO commented Feb 27, 2025

요약

전체 도메인에 대해 페이지네이션 목록 조회를 구현했습니다.



작업 내용

  • 세션 페이지네이션 목록 조회 구현
  • 프로필 페이지네이션 목록 조회 구현
  • 이력서 페이지네이션 목록 조회 구현
  • 블로그 페이지네이션 목록 조회 구현
  • 프로젝트/스터디 페이지네이션 목록 조회 구현
    • 바뀐 필터링 구성으로 requestDTO가 수정 되었습니다.
  • AlertServcie -> AlertService 오타 수정
  • 완성되지 않은 테스트 디렉토리 삭제



참고 사항



관련 이슈

SCRUM-259



Summary by CodeRabbit

  • 신규 기능
    • 블로그, 이력서, 세션, 사용자 프로필 등 다양한 목록 조회 API가 페이지네이션 메타데이터를 포함하도록 개선되어, 사용자께서 데이터를 보다 명확하게 탐색할 수 있습니다.
    • 프로젝트 및 스터디 팀 조회 기능이 새롭게 도입되어, 두 유형의 팀 정보를 일관된 형식과 함께 제공합니다.
  • 개선 사항
    • 응답 형식과 에러 로깅이 강화되어, 전반적인 데이터 처리 및 오류 추적이 더욱 일관되고 신뢰성 있게 향상되었습니다.

Copy link

coderabbitai bot commented Feb 27, 2025

워크스루

이번 PR에서는 페이지네이션 메타데이터를 관리하기 위한 신규 클래스 PagableMeta를 추가하고, 여러 API 엔드포인트(블로그, 이력서, 세션, 사용자 등)의 반환 타입을 기존 배열에서 데이터와 메타 정보를 함께 포함하는 객체로 변경하였습니다. 또한, 각 레이어(컨트롤러, 서비스, 리포지토리)의 관련 메서드 시그니처가 수정되었고, 모의 데이터 및 테스트 코드도 이러한 변경 사항에 맞게 업데이트되었습니다. 일부 테스트 파일이 삭제되고, 명명 오류, import 경로, 패키지 버전 등의 소소한 수정도 함께 이루어졌습니다.

변경사항

파일 경로 그룹 변경 요약
페이지네이션 및 메타데이터 관련
- src/global/pagable/pageble-meta.ts
- src/modules/blogs/{blog.controller.ts, blog.service.ts, repository/blog.repository.ts}
- src/modules/resumes/{resume.controller.ts, resume.service.ts, repository/resume.repository.ts}
- src/modules/sessions/{session.controller.ts, session.service.ts, repository/session.repository.ts}
- src/modules/users/{user.controller.ts, user.service.ts, repository/user.repository.ts}
각 도메인의 조회 메서드(getBlogList, getResumeList, getSessionList, getAllProfiles 등)가 단순 배열 반환에서 페이지네이션 정보(PagableMeta 또는 total)를 포함하는 객체로 변경됨.
테스트 및 모의데이터 업데이트
- src/modules/blogs/test/*
- src/modules/resumes/test/*
- src/modules/sessions/test/*
테스트에서 반환값(mock data)이 blogMetaMock, resumeMetaMock, sessionMetaMock 등으로 업데이트되고, 각 리포지토리 모의 객체에 count 메서드와 IndexService 제공자가 추가됨.
삭제된 테스트 파일
- src/modules/projectTeams/test/*
- src/modules/studyTeams/test/*
- src/modules/studyMembers/test/*
- src/modules/users/test/*
프로젝트 팀, 스터디 팀, 스터디 멤버, 사용자 관련 여러 테스트 및 모의데이터 파일이 완전히 삭제됨.
모듈 및 명명, 패키지 수정
- src/modules/alert/{alert.module.ts, alert.service.ts}
- src/modules/studyTeams/studyTeam.service.ts
- src/modules/projectTeams/projectTeam.service.ts
- package.json
AlertServcie의 오타가 AlertService로 수정되고, 관련 import 구문이 업데이트됨. 또한, TypeScript 버전이 ^5.5.4에서 ^5.7.3으로 업그레이드됨.
프로젝트 팀 신규 기능 및 DTO/응답 구조 추가
- src/modules/projectTeams/dto/request/get.team.query.request.ts
- src/modules/projectTeams/dto/response/get.allTeams.response.ts
- src/modules/projectTeams/repository/projectTeam.repository.ts
- src/modules/projectTeams/projectTeam.controller.ts
단일 팀 타입(teamType)과 pagination(offset, limit)을 포함하는 DTO로 변경되었으며, getAllTeams 메서드 및 관련 응답 클래스(GetAllTeamsResponse, FormattedProject, FormattedStudy)가 추가되어 프로젝트 팀 조회 기능이 개선됨. 파라미터 명칭과 오류 로깅도 수정됨.
기타 모듈 import 경로 재정렬
- src/modules/studyMembers/studyMember.module.ts
- src/modules/studyTeams/studyTeam.module.ts
import 순서 및 경로가 정리되어 가독성을 높임 (기능 변경 없음).

시퀀스 다이어그램

아래 다이어그램은 프로젝트 팀 조회(getAllTeams) 기능의 주요 흐름을 단순화하여 나타냅니다.

sequenceDiagram
    participant C as Client
    participant PC as ProjectTeamController
    participant PS as ProjectTeamService
    participant PR as ProjectTeamRepository
    participant DB as Database

    C->>PC: getAllTeams(request)
    PC->>PS: getAllTeams(request)
    PS->>PR: getAllTeams(request)
    PR->>DB: 팀 데이터 및 total count 조회
    DB-->>PR: 팀 데이터, total count
    PR-->>PS: { teams, total }
    PS-->>PC: { teams, meta: PagableMeta }
    PC-->>C: { teams, meta }
Loading

귀여운 토끼가 전하는 변화의 노래

새롭게 태어난 PagableMeta,
API에 빛나는 메타 정보를 더하고,
테스트와 코드, 정리된 길 위를 달려요. 🐇
버그는 사라지고, 코드의 향연 속에
우리 모두 희망을 노래합니다!

(토끼의 꼬리처럼 살랑살랑~)

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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

@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 (5)
src/global/pagable/pageble-meta.ts (1)

1-13: Good implementation of pagination metadata!

The PagableMeta class effectively encapsulates pagination-related information with all the necessary properties needed for client-side pagination handling. The calculations in the constructor are correct and efficiently determine pagination values.

However, there appears to be a typo in the filename and path: "pagable" instead of "pageable". Consider renaming for consistency with standard English terminology.

src/modules/blogs/blog.controller.ts (1)

96-97: Return type correctly updated for pagination support.

The method signature is properly updated to include both the blogs data and pagination metadata in the response.

Like the other controllers, methods such as getBestBlogs and getBlogsByUser still return arrays without pagination metadata. For a consistent API experience, you might want to apply the same pagination pattern to these methods as well.

-async getBestBlogs(
-    @Query() query: PaginationQueryDto,
-): Promise<GetBlogResponse[]> {
+async getBestBlogs(
+    @Query() query: PaginationQueryDto,
+): Promise<{ blogs: GetBlogResponse[]; meta: PagableMeta }> {
src/modules/sessions/repository/session.repository.ts (1)

117-153: Great concurrency approach.
The concurrent retrieval of the session list and total count via Promise.all is a solid optimization. Additionally, consider specifying an explicit ordering (e.g., by creation date) to ensure consistent results across multiple queries.

src/modules/users/user.service.ts (1)

398-439: New pagination response structure.
Returning an object with users and meta provides a clear structure for pagination. Consider validating query.offset and query.limit to prevent any unexpected behavior when these values are negative or excessively large.

src/modules/users/repository/user.repository.ts (1)

538-538: Revisit error construction.
Using throw Error(error) makes it difficult to distinguish and handle this error downstream. Consider rethrowing the original error or wrapping it suitably, for instance throw new Error(error.message) or a custom error class, to provide more clarity.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b7017fb and 58e1f17.

📒 Files selected for processing (14)
  • prisma/seed.ts (1 hunks)
  • src/global/pagable/pageble-meta.ts (1 hunks)
  • src/modules/blogs/blog.controller.ts (2 hunks)
  • src/modules/blogs/blog.service.ts (2 hunks)
  • src/modules/blogs/repository/blog.repository.ts (4 hunks)
  • src/modules/resumes/repository/resume.repository.ts (3 hunks)
  • src/modules/resumes/resume.controller.ts (2 hunks)
  • src/modules/resumes/resume.service.ts (2 hunks)
  • src/modules/sessions/repository/session.repository.ts (1 hunks)
  • src/modules/sessions/session.controller.ts (2 hunks)
  • src/modules/sessions/session.service.ts (2 hunks)
  • src/modules/users/repository/user.repository.ts (2 hunks)
  • src/modules/users/user.controller.ts (2 hunks)
  • src/modules/users/user.service.ts (4 hunks)
✅ Files skipped from review due to trivial changes (1)
  • prisma/seed.ts
🧰 Additional context used
🪛 Biome (1.9.4)
src/modules/users/repository/user.repository.ts

[error] 522-523: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (28)
src/modules/resumes/resume.controller.ts (2)

26-26: Import addition for pagination metadata looks good.

The import of the PagableMeta class is correctly added to support the updated return type.


43-44:

❓ Verification inconclusive

Return type correctly updated for pagination support.

The method signature is properly updated to include both the resume data and pagination metadata in the response.

However, note that other methods like getBestResumes and getResumesByUser still return arrays without pagination metadata. You might want to update these methods for consistency across your API.


🏁 Script executed:

#!/bin/bash
# Check if other methods in the codebase use pagination
rg "Promise<\w+Response\[\]>" src/modules --type ts

Length of output: 3388


Pagination update confirmed in resume.controller.ts

The resume endpoint now correctly returns both the resumes and pagination metadata. However, our search output confirms that several methods in this and other modules (e.g., getBestResumes and getResumesByUser in resumes, along with similar patterns in blogs, events, project teams, etc.) still return plain arrays (using Promise<Get*Response[]>). Please review these endpoints to decide if they also need to be updated for a consistent API design.

src/modules/sessions/session.controller.ts (2)

25-25: Import addition for pagination metadata looks good.

The import of the PagableMeta class is correctly added to support the updated return type.


91-92: Return type correctly updated for pagination support.

The method signature is properly updated to include both the sessions data and pagination metadata in the response.

Similar to the resume controller, other methods like getBestSessions and getSessionsByUser still return arrays without pagination metadata. Consider updating these for consistency.

src/modules/blogs/blog.controller.ts (1)

21-21: Import addition for pagination metadata looks good.

The import of the PagableMeta class is correctly added to support the updated return type.

src/modules/users/user.controller.ts (2)

30-30: Good addition of PagableMeta import.

The import statement is necessary for the return type change in the getAllProfiles method.


496-498: Return type enhancement to include pagination metadata.

The return type change from Promise<GetUserResponse[]> to Promise<{ users: GetUserResponse[]; meta: PagableMeta }> properly implements pagination metadata in the API response, providing clients with necessary information for pagination UI components.

src/modules/blogs/blog.service.ts (2)

8-8: Appropriate import of PagableMeta.

The import statement is correctly added to support the enhanced pagination functionality.


26-43: Well-implemented pagination metadata structure.

The modified getBlogList method now properly returns both the blogs array and pagination metadata. The implementation correctly:

  1. Retrieves total blog count from the repository
  2. Creates a PagableMeta instance with the necessary parameters
  3. Returns a structured response with both data and metadata

This change enhances the API by providing valuable pagination context to consumers.

src/modules/resumes/resume.service.ts (2)

16-16: Good addition of PagableMeta import.

This import is correctly added to support the pagination metadata implementation.


104-122: Consistent implementation of pagination metadata.

The implementation follows the same pattern as other services, maintaining consistency across the application. The method correctly:

  1. Extracts resume data and total count from the repository response
  2. Creates a PagableMeta instance with appropriate parameters
  3. Returns a structured object with both the data and metadata

This consistent approach to pagination will improve the developer experience when working with these APIs.

src/modules/sessions/session.service.ts (2)

14-14: Appropriate import of PagableMeta.

The import statement is correctly added to support the enhanced pagination functionality.


70-92: Well-structured pagination implementation with good logging.

The implementation follows the same pattern as other services but with an additional improvement in the logging statement to include metadata information. The method:

  1. Correctly maps session entities to response DTOs
  2. Creates a PagableMeta instance with proper parameters
  3. Logs both the number of items and pagination metadata
  4. Returns a well-structured response object

This enhanced logging will be helpful for debugging pagination-related issues.

src/modules/users/user.service.ts (1)

27-27: Import looks good.
Kudos for properly importing the new PagableMeta dependency.

src/modules/users/repository/user.repository.ts (3)

393-395: Enhanced pagination support.
Exposing both users and total makes the API more versatile for pagination use cases. Good choice!


522-523: Ignore the static analysis recommendation.
The suggestion to use optional chaining is a false positive since filters is a defined object. No change is required here.

🧰 Tools
🪛 Biome (1.9.4)

[error] 522-523: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


529-532: Consistent return structure.
Returning { users, total } aligns well with the new pagination approach across the codebase.

src/modules/blogs/repository/blog.repository.ts (6)

95-97: API change: Return type now includes pagination metadata.

The return type of getBlogList has been updated to include both the blog list and the total count. This appears to be part of a larger change to support pagination metadata throughout the application.


107-121: Improved ordering with multiple criteria.

The query now orders blogs by both like count and creation date, prioritizing popular content first and then the most recent. This is a good improvement for content relevance.


129-130: Updated log message to reference the new variable name.

The debug log message has been updated to reference blogentities.length instead of the previous variable name, maintaining logging consistency.


132-136: Updated return structure to include pagination metadata.

The return structure now includes both the blogs array and the total count, which is consistent with the method signature change and supports pagination implementation.


122-127:

✅ Verification successful

Added separate count query for pagination.

A separate query has been added to count the total number of blogs matching the criteria, which is necessary for pagination. Consider potential performance implications of running two queries instead of one.


🏁 Script executed:

#!/bin/bash
# Check if this pattern is consistent across other repository methods
# to confirm this is an intentional architectural decision

echo "Checking for similar count query patterns in other repository files:"
rg -A 3 "count\(\{" --type ts src/modules

Length of output: 2822


Verified Separate Count Query for Pagination Usage

The implementation in src/modules/blogs/repository/blog.repository.ts (lines 122–127) follows the same pattern observed in other modules (e.g., studyMembers, likes, resumes). This consistency confirms that using a separate count query for pagination is an intentional architectural decision. While running two queries may have performance implications, the approach is already prevalent across the codebase.


179-180:

✅ Verification successful

Changed date filter field from 'date' to 'createdAt'.

The SQL query now filters on createdAt instead of date, which appears to be for consistency with the entity structure.


🏁 Script executed:

#!/bin/bash
# Verify that this change is consistent with the Blog entity structure
# and that other queries using date filtering have been similarly updated

echo "Checking Blog entity structure:"
rg "class BlogEntity" -A 20 --type ts src/modules/blogs/entities/

echo "\nChecking other date-related queries in blog repository:"
rg "date(\s|\)).*Blog" --type ts src/modules/blogs/

Length of output: 1502


SQL Filter Update Approved

The query in src/modules/blogs/repository/blog.repository.ts now correctly filters blogs based on the createdAt field, which is defined in the Blog entity (see src/modules/blogs/entities/blog.entity.ts). The additional search didn’t reveal any other date-related queries using the old field, so this change appears consistent with the intended design.

src/modules/resumes/repository/resume.repository.ts (5)

127-129: API change: Return type now includes pagination metadata.

Similar to the blog repository, the return type has been updated to include both the resume list and the total count to support pagination.


154-156: Using the extracted whereCondition object.

The query now uses the extracted whereCondition object, which is consistent with the refactoring approach.


165-165: Added separate count query for pagination.

Similar to the blog repository, a separate query has been added to count total resumes matching the criteria.


170-176: Updated return structure to include pagination metadata.

The processing of resume entities has been refactored to store the mapped results in a variable before returning, and the return structure now includes both the resumes array and the total count.


141-153:

✅ Verification successful

Improved code organization with a separate whereCondition object.

Extracting the filter conditions into a separate object improves readability and ensures consistent conditions between the main query and count query.

Note: There appears to be a commented-out condition on line 144 that was filtering on the user's main position but now filters directly on the resume's position field. Verify this change is intentional.


🏁 Script executed:

#!/bin/bash
# Check if this is an intentional change to the filtering logic
# by examining the Resume entity and related service usage

echo "Examining Resume entity structure:"
rg "class ResumeEntity" -A 20 --type ts src/modules/resumes/entities/

echo "\nLooking for references to position filtering:"
rg "position.*in.*" --type ts src/modules/resumes/

Length of output: 2500


Confirmation of Intentional Filter Logic Adjustment

The change from filtering on user.mainPosition to filtering directly on the resume’s position field is intentional. The separate whereCondition object improves readability and enforces consistent conditions between the main query and the count query. Verification confirms that:

  • The ResumeEntity defines position as a string and it is the property being filtered.
  • References across the codebase (in DTOs, services, and tests) consistently use resume.position for filtering.

Approved as-is.

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 (2)
src/modules/resumes/test/resume.service.spec.ts (2)

66-69: IndexService 테스트 제공자가 추가됨

테스트 모듈에 IndexService 제공자가 추가되었습니다. 현재 빈 객체로 구현되어 있는데, 만약 이 서비스가 테스트에서 직접 사용되는 경우 모의 구현을 추가하는 것이 좋을 수 있습니다.

서비스가 테스트 중인 메서드에서 사용되는 경우 다음과 같이 구현할 수 있습니다:

{
    provide: IndexService,
-    useValue: {},
+    useValue: {
+        // IndexService의 필요한 메서드들에 대한 모의 구현 추가
+        // 예: search: jest.fn(),
+    },
},

190-190: getResumeList 결과 변수의 타입 주석 제거

결과 변수에 타입 주석이 없어졌습니다. TypeScript가 타입을 추론할 수 있지만, 명시적 타입 지정이 코드 가독성을 향상시킬 수 있습니다.

명확성을 위해 타입 주석을 추가하는 것이 좋습니다:

- const result = await service.getResumeList(getResumesQueryRequest);
+ const result: typeof resumeMetaMock = await service.getResumeList(getResumesQueryRequest);
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 58e1f17 and ff219f9.

📒 Files selected for processing (26)
  • prisma/seed.ts (2 hunks)
  • src/modules/blogs/test/blog.controller.spec.ts (2 hunks)
  • src/modules/blogs/test/blog.repository.spec.ts (3 hunks)
  • src/modules/blogs/test/blog.service.spec.ts (2 hunks)
  • src/modules/blogs/test/mock-data.ts (2 hunks)
  • src/modules/likes/test/like.repository.spec.ts (2 hunks)
  • src/modules/projectTeams/test/mock-data.ts (0 hunks)
  • src/modules/projectTeams/test/projectTeam.controller.spec.ts (0 hunks)
  • src/modules/projectTeams/test/projectTeam.repository.spec.ts (0 hunks)
  • src/modules/projectTeams/test/projectTeam.service.spec.ts (0 hunks)
  • src/modules/resumes/test/mock-data.ts (2 hunks)
  • src/modules/resumes/test/resume.controller.spec.ts (2 hunks)
  • src/modules/resumes/test/resume.repository.spec.ts (2 hunks)
  • src/modules/resumes/test/resume.service.spec.ts (4 hunks)
  • src/modules/sessions/test/mock-data.ts (2 hunks)
  • src/modules/sessions/test/session.controller.spec.ts (2 hunks)
  • src/modules/sessions/test/session.repository.spec.ts (2 hunks)
  • src/modules/sessions/test/session.service.spec.ts (3 hunks)
  • src/modules/studyMembers/test/studyMember.repository.spec.ts (0 hunks)
  • src/modules/studyTeams/test/mock-data.ts (0 hunks)
  • src/modules/studyTeams/test/studyTeam.controller.spec.ts (0 hunks)
  • src/modules/studyTeams/test/studyTeam.repository.spec.ts (0 hunks)
  • src/modules/studyTeams/test/studyTeam.service.spec.ts (0 hunks)
  • src/modules/users/test/user.controller.spec.ts (0 hunks)
  • src/modules/users/test/user.repository.spec.ts (0 hunks)
  • src/modules/users/test/user.service.spec.ts (0 hunks)
💤 Files with no reviewable changes (12)
  • src/modules/projectTeams/test/projectTeam.controller.spec.ts
  • src/modules/studyTeams/test/studyTeam.service.spec.ts
  • src/modules/users/test/user.controller.spec.ts
  • src/modules/studyTeams/test/studyTeam.repository.spec.ts
  • src/modules/users/test/user.service.spec.ts
  • src/modules/studyTeams/test/studyTeam.controller.spec.ts
  • src/modules/projectTeams/test/projectTeam.service.spec.ts
  • src/modules/projectTeams/test/mock-data.ts
  • src/modules/users/test/user.repository.spec.ts
  • src/modules/projectTeams/test/projectTeam.repository.spec.ts
  • src/modules/studyMembers/test/studyMember.repository.spec.ts
  • src/modules/studyTeams/test/mock-data.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • prisma/seed.ts
🔇 Additional comments (40)
src/modules/blogs/test/mock-data.ts (2)

6-6: metaMock 모듈 가져오기 추가.

세션 모듈에서 메타 데이터 목 객체를 가져와서 블로그 테스트에 활용하는 변경사항입니다. 이는 페이지네이션 메타데이터 통합을 위한 적절한 접근입니다.


77-80: 페이지네이션 메타데이터를 포함하는 블로그 응답 목 객체 추가됨.

블로그 목록과 메타데이터를 결합한 blogMetaMock 객체를 생성하여 페이지네이션 기능이 포함된 응답 테스트를 지원합니다. 이 구현은 블로그 컨트롤러와 서비스 테스트에서 활용되며 일관된 응답 형식을 제공합니다.

src/modules/resumes/test/resume.repository.spec.ts (3)

36-36: 이력서 테스트를 위한 count 목 함수 추가.

페이지네이션 메타데이터 구현을 위해 필요한 count 목 함수가 추가되었습니다. 이는 전체 이력서 개수를 계산하는 데 사용됩니다.


133-133: 총 이력서 개수를 반환하는 count 메서드 목 구현.

prismaService.resume.count에 대한 목 구현이 추가되어 테스트에서 총 이력서 개수를 1로 반환합니다. 이는 페이지네이션 메타데이터 테스트에 필요한 부분입니다.


139-142: 응답 형식에 페이지네이션 메타데이터 포함 추가.

이전에는 단순 이력서 목록만 반환하던 것에서 이제는 이력서 목록과 총 개수를 포함하는 객체를 반환하도록 변경되었습니다. 이 변경은 API 응답 구조 개선에 도움이 됩니다.

src/modules/blogs/test/blog.repository.spec.ts (4)

32-32: 블로그 테스트를 위한 count 목 함수 추가.

블로그 목록의 페이지네이션 메타데이터를 지원하기 위해 필요한 count 목 함수가 추가되었습니다. 이는 다른 모듈에서도 사용된 일관된 패턴입니다.


85-85: 총 블로그 개수를 반환하는 count 메서드 목 구현.

prismaService.blog.count에 대한 목 구현이 추가되어 테스트에서 총 블로그 개수를 1로 반환합니다. 이는 페이지네이션 테스트에 필요한 부분입니다.


89-92: 응답 형식에 페이지네이션 메타데이터 포함 추가.

블로그 목록과 함께 총 개수(total)를 포함하는 객체를 반환하도록 변경되었습니다. 이 변경은 페이지네이션 기능 구현에 필수적이며 다른 모듈과의 일관성을 유지합니다.


105-108: 정렬 방식 개선을 위한 orderBy 구문 변경.

단일 정렬 기준에서 복수 정렬 기준으로 변경하여 먼저 좋아요 수(likeCount)로 내림차순 정렬한 후, 생성일(createdAt)로 내림차순 정렬하도록 개선되었습니다. 이로써 좋아요 수가 같은 블로그들 사이에서도 일관된 정렬이 가능해집니다.

src/modules/resumes/test/mock-data.ts (2)

8-8: metaMock 모듈 가져오기 추가.

세션 모듈에서 메타 데이터 목 객체를 가져와서 이력서 테스트에 활용하는 적절한 변경사항입니다. 이는 다른 모듈들과 일관된 패턴을 따릅니다.


105-108: 페이지네이션 메타데이터를 포함하는 이력서 응답 목 객체 추가됨.

이력서 목록과 메타데이터를 결합한 resumeMetaMock 객체가 생성되었습니다. 이는 블로그 모듈과 동일한 패턴으로, 페이지네이션 기능이 포함된 응답을 테스트하는 데 사용됩니다. 이러한 일관된 접근 방식은 코드베이스 전반의 통일성을 높입니다.

src/modules/sessions/test/session.controller.spec.ts (3)

14-14: 세션 메타데이터 모의 객체 추가.

mock-data에서 새로운 sessionMetaMock을 임포트하는 것은 페이지네이션 기능 구현에 적절합니다.


122-123: 서비스 모의 응답이 페이지네이션 메타데이터를 포함하도록 업데이트.

getSessionList 메서드의 반환값을 sessionMetaMock으로 변경하여 페이지네이션 메타데이터를 포함한 응답을 테스트할 수 있습니다.


129-129: 테스트 기대값을 페이지네이션 메타데이터를 포함하도록 수정.

기대값이 단순 세션 목록에서 메타데이터가 포함된 구조로 변경되어 API 스펙 변경을 정확히 반영합니다.

src/modules/likes/test/like.repository.spec.ts (2)

9-9: IndexService 임포트 추가.

인덱싱 기능을 위한 서비스를 임포트하여 테스트 구성을 준비합니다.


54-57:

✅ Verification successful

테스트에 IndexService 모의 객체 추가.

IndexService를 테스트 모듈에 빈 구현체로 제공하여 의존성을 해결했습니다. 하지만 현재 테스트에서는 이 서비스의 기능을 검증하지 않습니다.


🏁 Script executed:

#!/bin/bash
# IndexService가 LikeRepository에서 실제로 사용되는지 확인
rg -A 2 "IndexService" --type ts src/modules/likes/repository/like.repository.ts

Length of output: 289


의존성 주입 해결 및 모의 객체 사용 검증 완료

  • 테스트 모듈에서 IndexService에 대해 빈 객체(useValue: {})를 제공한 것은, 실제 LikeRepository에서 IndexService가 주입되어 사용되는 것을 확인한 결과(코드 내 private readonly indexService: IndexService 참조) 의존성 해결을 위한 적절한 처치입니다.
  • 현재 테스트는 IndexService의 기능이 구체적으로 검증되지 않으므로, 해당 서비스의 동작 검증이 요구된다면 별도의 단위 테스트나 상세 모의 객체 구현을 추가하는 것을 고려해 주세요.
src/modules/sessions/test/mock-data.ts (3)

8-8: PagableMeta 클래스 임포트 추가.

페이지네이션 메타데이터 구조를 정의하는 클래스를 적절히 임포트했습니다.


147-152: 페이지네이션 메타데이터 모의 객체 구현.

페이지네이션에 필요한 메타데이터(totalItems, totalPages, currentPage, hasNextPage)를 포함하는 metaMock 객체를 잘 구현했습니다.


154-157: 세션 목록과 메타데이터를 포함하는 복합 응답 객체 구현.

sessions와 meta 속성을 포함하는 sessionMetaMock 객체를 생성하여 API 응답 구조를 정확히 모델링했습니다.

src/modules/resumes/test/resume.controller.spec.ts (3)

10-10: 이력서 메타데이터 모의 객체 추가.

mock-data에서 resumeMetaMock을 임포트하여 페이지네이션 테스트 준비가 적절히 이루어졌습니다.


149-150: getResumeList 서비스 반환값 업데이트.

이력서 목록 조회 메서드의 반환값이 페이지네이션 메타데이터를 포함하도록 적절히 변경되었습니다.


156-156: 테스트 기대값 업데이트로 API 변경 반영.

테스트의 기대값이 resumeMetaMock을 사용하도록 변경되어 API 응답 구조의 변경을 정확히 반영합니다.

src/modules/blogs/test/blog.controller.spec.ts (3)

5-5: blogMetaMock 임포트 추가 확인

페이지네이션 메타데이터를 포함하는 새로운 형식으로 테스트가 업데이트되었습니다. 좋은 변경사항입니다.


73-73: 테스트 모킹 데이터 업데이트 확인

getBlogList 메서드의 반환값이 단순 블로그 목록에서 메타데이터를 포함하는 객체로 변경되었습니다.


77-77: 테스트 기대값 업데이트 확인

페이지네이션 메타데이터가 포함된 새로운 응답 구조에 맞게 테스트 기대값이 정확히 업데이트되었습니다.

src/modules/sessions/test/session.service.spec.ts (5)

17-17: sessionMetaMock 임포트 추가 확인

페이지네이션 메타데이터를 포함하는 새로운 형식의 테스트 데이터가 추가되었습니다.


22-22: IndexService 임포트 추가 확인

IndexService 의존성이 추가되었습니다.


52-58: IndexService 모킹 추가 확인

IndexService 모킹이 테스트 모듈에 적절히 추가되었습니다. 인덱싱 기능을 테스트할 준비가 되었습니다.


129-132: getSessionList 모킹 반환값 업데이트 확인

getSessionList 메서드의 반환값이 단순 세션 목록에서 세션 목록과 총 개수를 포함하는 객체로 변경되었습니다.


138-138: 테스트 기대값 업데이트 확인

페이지네이션 메타데이터가 포함된 새로운 응답 구조에 맞게 테스트 기대값이 정확히 업데이트되었습니다.

src/modules/blogs/test/blog.service.spec.ts (3)

5-5: blogMetaMock 임포트 추가 확인

페이지네이션 메타데이터를 포함하는 새로운 형식으로 테스트가 업데이트되었습니다.


88-91: getBlogList 모킹 반환값 업데이트 확인

getBlogList 메서드의 반환값이 단순 블로그 목록에서 블로그 목록과 총 개수를 포함하는 객체로 변경되었습니다. 이는 페이지네이션 메타데이터 통합에 필요한 적절한 변경사항입니다.


95-95: 테스트 기대값 업데이트 확인

페이지네이션 메타데이터가 포함된 새로운 응답 구조에 맞게 테스트 기대값이 정확히 업데이트되었습니다.

src/modules/sessions/test/session.repository.spec.ts (3)

34-34: count 메서드 모킹 추가 확인

세션 총 개수를 계산하기 위한 count 메서드 모킹이 추가되었습니다.


182-182: count 스파이 설정 확인

count 메서드에 대한 스파이가 적절히 설정되었고 반환값이 1로 설정되었습니다.


188-191: 테스트 결과 확인 업데이트 확인

테스트 결과가 세션 목록과 함께 총 개수를 포함하는 객체로 업데이트되었습니다. 페이지네이션 메타데이터 통합을 위한 적절한 변경사항입니다.

src/modules/resumes/test/resume.service.spec.ts (4)

10-10: resumeMetaMock 가져오기가 추가됨

페이지네이션 메타데이터를 포함하는 새로운 반환 구조를 테스트하기 위해 resumeMetaMock을 import 했습니다. 이는 이제 서비스가 단순 목록이 아닌 메타데이터가 포함된 응답을 반환하도록 변경되었음을 나타냅니다.


19-19: IndexService 가져오기가 추가됨

IndexService를 가져오는 것은 이 서비스가 이제 ResumeService의 의존성으로 추가되었음을 나타냅니다. 인덱싱 또는 검색 기능과 관련이 있을 것으로 추정됩니다.


185-188: getResumeList 반환 구조 변경

getResumeList 메서드의 모의 구현이 이제 단순 배열이 아닌 resumestotal 속성을 포함하는 객체를 반환하도록 변경되었습니다. 이는 페이지네이션 메타데이터 지원을 위한 적절한 변경입니다.


192-192: 검증 대상 변경

테스트 검증이 이제 getResumeResponseList 대신 resumeMetaMock을 사용합니다. 이는 메서드가 이제 페이지네이션 메타데이터를 포함하는 새로운 구조를 반환한다는 사실과 일치합니다.

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: 1

🧹 Nitpick comments (12)
src/modules/sessions/repository/session.repository.ts (2)

135-150: Promise.all을 사용한 효율적인 데이터 조회 구현이 좋습니다.

데이터 조회와 카운트 연산을 병렬로 처리하여 API 응답 시간을 단축시킨 점이 좋습니다. 다만, orderBy 설정이 'title' 기준인데, 세션의 경우 날짜나 최신순이 더 일반적입니다.

다음과 같이 정렬 기준을 날짜나 생성일 기준으로 변경하는 것을 고려해보세요:

orderBy: {
-    title: 'asc',
+    createdAt: 'desc', // 또는 date: 'desc'
},

152-155: 응답 구조가 명확하게 정의되어 있습니다.

세션 목록과 총 개수를 포함하는 객체를 반환하는 구조로, 페이지네이션을 위한 메타데이터 활용에 적합합니다.

타입 안정성을 위해 별도의 인터페이스로 반환 타입을 정의하는 것이 좋을 수 있습니다:

interface SessionListResult {
  sessions: SessionEntity[];
  total: number;
}

async getSessionList(
  query: GetSessionsQueryRequest
): Promise<SessionListResult> {
  // 기존 로직...
}
src/modules/resumes/repository/resume.repository.ts (3)

143-146: 주석 처리된 코드를 제거하세요.

코드 품질을 향상시키기 위해 주석 처리된 필터링 로직(user: { mainPosition: { in: position } })을 제거하는 것이 좋습니다. 주석 처리된 코드는 코드 품질을 저하시키고 혼란을 줄 수 있습니다.

const whereCondition = {
    isDeleted: false,
    ...(position?.length && {
-        // user: { mainPosition: { in: position } }, // 유저 포지션
        position: { in: position },
    }),

94-125: 다른 조회 메서드도 일관성 있게 업데이트하는 것을 고려하세요.

getResumeList 메서드는 이제 { resumes, total } 구조를 반환하지만, getBestResumesgetResumesByUser 메서드는 여전히 배열만 반환합니다. 일관된 API 응답 구조를 위해 이 메서드들도 동일한 패턴으로 업데이트하는 것이 좋습니다.

// getBestResumes 예시
- async getBestResumes(query: PaginationQueryDto): Promise<GetResumeResponse[]> {
+ async getBestResumes(query: PaginationQueryDto): Promise<{ resumes: GetResumeResponse[]; total: number }> {
    // ... 기존 코드 ...
-   return resumesWithUser.map((resume) => new GetResumeResponse(resume));
+   const resumeResponse = resumesWithUser.map((resume) => new GetResumeResponse(resume));
+   const total = await this.prisma.resume.count({
+       where: {
+           isDeleted: false,
+           createdAt: { gte: twoWeeksAgo }
+       }
+   });
+   return {
+       resumes: resumeResponse,
+       total,
+   };
}

// getResumesByUser 예시도 비슷하게 변경

Also applies to: 179-207


165-165: count 쿼리에 대한 오류 처리 추가를 고려하세요.

total 값을 가져오는 쿼리에 오류 처리가 없습니다. 데이터베이스 쿼리가 실패할 경우에 대비한 오류 처리를 추가하는 것이 좋습니다.

- const total = await this.prisma.resume.count({ where: whereCondition });
+ const total = await this.prisma.resume.count({ where: whereCondition })
+   .catch((error) => {
+     this.logger.error(
+       `이력서 총 개수 조회 실패: ${error.message}`,
+       ResumeRepository.name,
+     );
+     return 0; // 기본값 반환
+   });
src/modules/studyTeams/repository/studyTeam.repository.ts (1)

15-16: 페이지네이션이 적용된 스터디팀 목록 조회 기능 추가

getStudyTeamsList 메서드가 적절하게 구현되어 있습니다. PagableMeta 구조를 활용한 페이지네이션 처리와 필터링 로직이 잘 작성되었습니다.

몇 가지 사항을 확인해 보세요:

  • 쿼리 조건이 복잡해질 경우를 대비해 분리된 함수로 조건부 필터링 로직을 추출하는 것도 고려해볼 수 있습니다.
  • 스터디 팀 정보에 필요한 모든 필드가 선택되었는지 확인하세요.

Also applies to: 25-69

src/modules/users/repository/user.repository.ts (1)

522-528: 전체 사용자 수 계산 로직 반영에 대한 성능 검토 권장
user.findMany에 이어서 user.count를 별도로 호출하는 방식은 문제없으나, 대규모 데이터셋일 경우 두 번의 쿼리 수행으로 인한 성능 지연이 발생할 수 있습니다. 필요 시 하나의 쿼리에서 집계 결과를 함께 가져오는 방안도 고려해 보세요.

Also applies to: 530-533

🧰 Tools
🪛 Biome (1.9.4)

[error] 523-524: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

src/modules/projectTeams/dto/response/get.allTeams.response.ts (2)

16-55: FormattedProject 생성자에 any 타입 사용 개선 제안
project 매개변수에 대한 구조 정의가 불명확하여, 추후 타입 안정성이 떨어질 위험이 있습니다. DTO나 별도의 인터페이스를 활용해 project 매개변수의 구조를 명확히 지정해 주세요.


57-79: FormattedStudy 생성자에 any 타입 사용 개선 제안
FormattedProject와 동일하게 study 매개변수를 더욱 구체적으로 정의해 주시는 편이 유지 보수에 유리합니다.

src/modules/projectTeams/dto/request/get.team.query.request.ts (2)

60-67: offset 속성으로 페이지네이션 지원
offset을 통해 페이지네이션을 유연하게 지원하도록 설정한 점이 좋습니다. 단, 너무 큰 offset 값을 클라이언트가 임의로 전달할 경우 서버 부하가 커질 수 있으니, 최대 범위를 지정하거나 2차적 검증을 고려해 보세요.


69-76: limit 속성 추가 및 상한 검토 권장
limit 설정으로 한 번에 읽어올 데이터를 제한하는 것은 좋습니다. 다만, 필요 시 특정 상한선을 두어 서버 성능을 보호하는 방안을 고려 부탁드립니다.

src/modules/projectTeams/repository/projectTeam.repository.ts (1)

106-192: [포지션 필터 로직에서 Enum 활용 고려]

getProjectTeamList 메서드에서 positions 배열을 반복하며 필터를 구성하고 있습니다. 문자열 상수를 직접 매칭하는 대신 열거형(Enum)으로 정의하면 오타를 방지하고 유지보수를 용이하게 할 수 있습니다. 또한, 정렬 기준(orderBy)이 없으므로, 불규칙적인 정렬 결과를 방지하려면 정렬 로직을 추가 고려해 보시길 권장합니다.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between aa3ffe0 and b81fcbe.

📒 Files selected for processing (15)
  • package.json (1 hunks)
  • src/modules/projectTeams/dto/request/get.team.query.request.ts (4 hunks)
  • src/modules/projectTeams/dto/response/get.allTeams.response.ts (1 hunks)
  • src/modules/projectTeams/projectTeam.module.ts (2 hunks)
  • src/modules/projectTeams/projectTeam.service.ts (2 hunks)
  • src/modules/projectTeams/repository/projectTeam.repository.ts (2 hunks)
  • src/modules/resumes/repository/resume.repository.ts (3 hunks)
  • src/modules/resumes/test/resume.repository.spec.ts (2 hunks)
  • src/modules/sessions/repository/session.repository.ts (1 hunks)
  • src/modules/sessions/test/session.repository.spec.ts (2 hunks)
  • src/modules/studyMembers/studyMember.module.ts (1 hunks)
  • src/modules/studyTeams/repository/studyTeam.repository.ts (2 hunks)
  • src/modules/studyTeams/studyTeam.module.ts (1 hunks)
  • src/modules/users/repository/user.repository.ts (2 hunks)
  • src/modules/users/user.service.ts (4 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/modules/studyMembers/studyMember.module.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/modules/resumes/test/resume.repository.spec.ts
  • src/modules/sessions/test/session.repository.spec.ts
🧰 Additional context used
🪛 Biome (1.9.4)
src/modules/users/repository/user.repository.ts

[error] 523-524: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (19)
package.json (1)

93-93: 타입스크립트 버전 업데이트 확인

"typescript" 의 버전이 "^5.5.4"에서 "^5.7.3"로 업데이트되었습니다. 최신 기능과 버그 수정 사항이 포함되어 있을 것으로 보이며, 변경된 TypeScript 버전에 따른 프로젝트 전반의 호환성 및 테스트 결과를 재확인하시기 바랍니다.

src/modules/sessions/repository/session.repository.ts (3)

117-117: 반환 타입이 개선되었습니다.

세션 목록과 함께 총 개수를 반환하는 구조로 변경되었습니다. 이는 페이지네이션 기능을 위한 좋은 접근 방식입니다.


126-132: 공통 where 조건 추출로 코드 가독성이 향상되었습니다.

여러 필터 조건을 하나의 객체로 통합하여 코드의 재사용성과 가독성이 향상되었습니다. 조건부 스프레드 구문 사용이 깔끔합니다.


115-156: 전체적인 메서드 구현이 잘 되어 있습니다.

페이지네이션을 포함한 세션 목록 조회 기능이 효율적으로 구현되었습니다. 다른 메서드들과의 일관성을 위해 예외 처리를 추가하는 것을 고려해 보세요.

해당 메서드에서 발생할 수 있는 예외 상황(DB 연결 오류 등)에 대한 처리가 다른 메서드들에 비해 부족합니다. try-catch 블록을 추가하여 일관된 에러 핸들링을 구현하는 것이 좋을 것 같습니다.

src/modules/resumes/repository/resume.repository.ts (1)

127-176: 페이징 처리를 위한 구조적 개선이 잘 이루어졌습니다.

whereCondition 객체를 분리하여 코드의 가독성과 유지보수성이 향상되었습니다. 또한 총 개수(total)를 반환하여 페이지네이션 처리에 필요한 정보를 제공하는 구조로 변경된 점이 좋습니다.

src/modules/studyTeams/studyTeam.module.ts (1)

1-3: 모듈 의존성 구조 개선

NestJS 모듈 구조가 더 명확하게 정리되었습니다. 상대 경로 사용과 circular dependency 처리를 위한 forwardRef 적용이 적절하게 이루어졌습니다.

  • ProjectTeamModule이 imports에 추가됨
  • forwardRef() 사용을 통한 순환 참조 문제 해결

Also applies to: 8-8, 11-11, 14-19

src/modules/projectTeams/projectTeam.module.ts (1)

1-1: 모듈 간 순환 참조 적절하게 처리됨

StudyTeamModuleStudyMemberModule의 의존성 관계를 적절하게 설정했습니다. forwardRef()를 사용한 순환 참조 처리가 올바르게 구현되었습니다.

Also applies to: 13-13, 16-23

src/modules/users/user.service.ts (1)

28-28: 사용자 프로필 조회 API 응답 구조 개선

getAllProfiles 메서드의 반환 타입이 PagableMeta를 포함하는 객체로 변경되어 페이지네이션 메타데이터를 함께 제공할 수 있게 되었습니다. 이는 API 응답 구조의 일관성을 높이는 좋은 개선사항입니다.

- async getAllProfiles(query: GetUserssQueryRequest): Promise<any>
+ async getAllProfiles(query: GetUserssQueryRequest): Promise<{ users: GetUserResponse[]; meta: PagableMeta }>

Also applies to: 407-447

src/modules/users/repository/user.repository.ts (1)

393-395: findAllProfiles 메서드의 반환 형식 확장
사용자 목록뿐 아니라 total까지 함께 반환하도록 변경된 점이 인상적입니다. 이렇게 하면 페이징이나 통계 정보를 손쉽게 활용할 수 있어 관리가 더욱 편리해집니다.

src/modules/projectTeams/dto/response/get.allTeams.response.ts (1)

3-14: GetAllTeamsResponse 클래스의 페이징 메타 정보 활용
페이징 메타(PagableMeta)와 팀 목록을 함께 관리해 응답 구조가 명확합니다. 페이지네이션 관련 정보와 실제 데이터를 한 번에 제공하는 설계가 우수해 보입니다.

src/modules/projectTeams/dto/request/get.team.query.request.ts (2)

1-3: Import 구문 추가 또는 변경
class-transformer, class-validator@nestjs/swagger가 함께 사용되어 DTO 검증을 간결하게 처리 중입니다. 특별한 문제는 없어 보이며, 호환성만 계속 주시해 주세요.


30-30: isFinished 속성의 선택 항목화 점검
@ApiPropertyOptional@IsBoolean() 조합을 통해 필수값이 아닌 불리언 필드를 선언한 점은 적절합니다. 다만, 문자열('true', 'false')을 변환할 때 혼선이 없도록 테스트를 충분히 진행해 보시기 바랍니다.

src/modules/projectTeams/projectTeam.service.ts (4)

28-35: 새로운 DTO 및 리포지토리 import
GetAllTeamsResponse, FormattedProject, FormattedStudy 등을 가져오며, StudyTeamRepository와의 의존관계를 명확히 선언한 점은 모듈 구조를 확장성 있게 만듭니다.


50-50: 생성자에 studyTeamRepository 추가
스터디 팀 관련 로직을 분리하여 StudyTeamRepository를 주입받는 것은 코드 구조가 명확해지며, 프로젝트 확장이 용이해집니다.


56-56: alertService 오타 수정
기존 AlertServcie에서 AlertService로 변경되어 가독성과 정확성이 향상되었습니다.


60-99: getAllTeams 메서드의 분기 처리 및 페이징 메타 생성
teamType으로 분기하여 프로젝트 또는 스터디 팀, 혹은 두 가지를 모두 조회하는 로직이 직관적이며, PagableMeta를 통해 조회 결과의 총 개수(result.total)를 함께 제공하여 클라이언트에서 페이징 처리가 쉽도록 설계한 점이 돋보입니다. 에러 발생 시 로깅과 함께 예외를 던지는 부분도 안정성이 높습니다.

src/modules/projectTeams/repository/projectTeam.repository.ts (3)

4-10: [Import 구문이 정상적으로 추가되었습니다]

새로운 DTO·예외 처리·Prisma 모델 등을 임포트하는 로직이 적절하게 반영되었습니다. 현재 코드 맥락에서는 문제가 없어 보입니다.


12-27: [타입 정의의 옵션 필드 처리 점검 권장]

TeamQueryResult에 포함된 다수의 속성이 optional(?)로 선언되어 있습니다. UNION 기반 쿼리 결과를 공통 타입으로 맞추기 위해 불가피해 보이지만, 이후 타입 변환 및 데이터 접근 시 런타임 에러 방지를 위해 주의가 필요합니다. 필요 시, default 값을 할당하거나 별도의 null 체크 로직을 함께 고려해 주세요.


36-104:

❓ Verification inconclusive

[Raw Query 사용 시 SQL 인젝션 및 타입 안전성 점검 필수]

getAllTeams 메서드 내에서 문자열로 직접 쿼리를 구성하고 $queryRawUnsafe를 호출하고 있습니다. TypeORM, Prisma 등 ORM/ODM 관계에서 별도 패러미터 바인딩 방식($queryRaw)을 고려하거나, isRecruited, isFinished 등이 확실히 boolean으로 검증되어 들어오는지 추가 점검이 필요합니다.

다음 스크립트를 통해 GetTeamQueryRequest 인터페이스 내 isRecruited, isFinished 속성이 boolean 타입으로 선언되어 있는지 확인해 주세요:


🏁 Script executed:

#!/bin/bash
# Description: GetTeamQueryRequest 인터페이스 정의에서 isRecruited·isFinished가 boolean으로 선언되어 있는지 검사
fd "get.team.query.request" --exec cat {} | rg -A 5 "interface GetTeamQueryRequest"

Length of output: 85


SQL 인젝션 위험 및 타입 검증 상태 확인 필요
getAllTeams 메서드에서 $queryRawUnsafe를 사용해 쿼리를 문자열로 구성함에 따라 SQL 인젝션 위험이 존재합니다. 또한, isRecruitedisFinished 값이 올바르게 boolean으로 검증되어 들어오는지 확인이 요구됩니다.
현재 자동화된 타입 검증 스크립트에서는 GetTeamQueryRequest 인터페이스 내 해당 필드의 boolean 선언 여부를 확인할 수 없어, 관련 타입 정의에 대해 수동 확인이 필요합니다.

  • 필수 검증 사항:
    • GetTeamQueryRequest 인터페이스 내의 isRecruitedisFinished 필드가 boolean 타입으로 선언되어 있는지 IDE나 직접 파일 검색 등으로 재검토해 주세요.
    • 가능하다면, $queryRawUnsafe 사용 대신 파라미터 바인딩 방식($queryRaw)을 활용해 SQL 인젝션 공격 위험을 줄이는 개선 작업을 고려해 주세요.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
18.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@dlwhsk0 dlwhsk0 self-assigned this Feb 28, 2025
@dlwhsk0 dlwhsk0 changed the title Scrum 259 fix: 페이지네이션 목록 조회 구현 Feb 28, 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: 0

🧹 Nitpick comments (4)
src/modules/projectTeams/projectTeam.service.ts (2)

28-34: [오탈자 주의] "PagableMeta" 네이밍을 재검토해보세요.
"PageableMeta" 등 더 직관적인 표기가 가독성에 도움이 될 수 있습니다.


58-97: [에러 처리] 일반 Error 대신 Custom Exception을 고려하세요.
현재 throw new Error('...')는 사용자 측에서 구체적인 정보를 제공받기 어렵습니다.

src/modules/projectTeams/repository/projectTeam.repository.ts (2)

19-139: [성능 개선] 대규모 데이터일 경우 전체를 조회 후 메모리에서 병합·페이징하는 것은 부담이 될 수 있습니다.
실시간 성능 요구사항이 높다면, UNION 등을 활용하거나 DB에서 바로 페이징하는 방식을 검토해보세요.


228-273: [스터디 리스트 조회] 프로젝트 리스트 조회와 유사한 구조로 일관성이 좋습니다.
추후 공통 로직을 묶어 간소화할 수도 있습니다.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b81fcbe and 471a79b.

📒 Files selected for processing (5)
  • src/modules/projectTeams/dto/request/get.team.query.request.ts (4 hunks)
  • src/modules/projectTeams/projectTeam.controller.ts (1 hunks)
  • src/modules/projectTeams/projectTeam.service.ts (2 hunks)
  • src/modules/projectTeams/repository/projectTeam.repository.ts (2 hunks)
  • src/modules/studyTeams/studyTeam.module.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/modules/studyTeams/studyTeam.module.ts
  • src/modules/projectTeams/dto/request/get.team.query.request.ts
🔇 Additional comments (4)
src/modules/projectTeams/projectTeam.controller.ts (3)

164-164: [파라미터명 변경] 더욱 직관적인 변수명입니다.
dto에서 request로 이름이 변경되어 사용 의도가 명확해졌습니다.


168-168: [코드 동작] 정상 동작을 확인해보세요.
request 객체를 인자로 전달하므로, 서비스 레이어에서 올바르게 매핑되는지 확인이 필요합니다.


170-173: [에러 로깅 개선] 에러 메시지에 컨트롤러 이름을 포함해 가독성이 향상되었습니다.
단, error 객체를 그대로 문자열로 변환할 때 원하는 정보가 모두 노출되는지 확인을 권장합니다.

src/modules/projectTeams/repository/projectTeam.repository.ts (1)

141-226: [프로젝트 리스트 조회] 로직 구조가 명확하여 유지보수 측면에서 적절합니다.
ORM 기반으로 페이지네이션이 잘 적용되어 있습니다.

@dlwhsk0 dlwhsk0 removed their request for review February 28, 2025 19:15
suhach0523
suhach0523 previously approved these changes Mar 1, 2025
Copy link
Contributor

@suhach0523 suhach0523 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다!!

@printSANO printSANO requested a review from suhach0523 March 1, 2025 07:14
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.

3 participants