Skip to content

fix#66

Merged
HoseokWon99 merged 1 commit into
prgrms-fullstack-devcourse:mainfrom
HoseokWon99:main
Aug 11, 2025
Merged

fix#66
HoseokWon99 merged 1 commit into
prgrms-fullstack-devcourse:mainfrom
HoseokWon99:main

Conversation

@HoseokWon99

Copy link
Copy Markdown
Contributor

유저 검색시 발생하는 오류 해결

@HoseokWon99 HoseokWon99 requested a review from ksy90101 as a code owner August 11, 2025 00:59
@HoseokWon99 HoseokWon99 merged commit 6f5f3de into prgrms-fullstack-devcourse:main Aug 11, 2025
1 check passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Summary of Changes

Hello @HoseokWon99, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've addressed an error encountered during user search by refactoring how age-based filtering is handled. Previously, age conversion was done in an interceptor; now, it's handled directly within the controller for better control and clarity. Additionally, I've updated the README.md with a troubleshooting guide regarding server performance.

Highlights

  • Refactored Age-Based User Search: The logic for converting an age range query parameter into a birthyear range for user search has been moved from a global interceptor to the UsersController's searchAdjacentUsers method. This centralizes the age conversion directly where the search request is handled.
  • API Query Parameter Update: The SearchAdjacentUsersQuery DTO now explicitly accepts an optional age range parameter, simplifying the query structure and making the API contract clearer for age-based filtering.
  • Endpoint Renaming: The /api/users/subscriptions endpoint has been renamed to /api/users/search/subscriptions to improve clarity and maintain consistency with other search-related endpoints.
  • Documentation Update: A new "Troubleshooting Experience" section has been added to README.md, detailing issues and solutions encountered related to server performance, Docker builds, and AWS t2 micro instances.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request aims to fix an issue with user search. It refactors the logic for handling age-based search filters, moving it from an interceptor to the controller for better separation of concerns. It also adds a detailed troubleshooting guide to the README.md about performance issues encountered during deployment.

My review identifies a critical issue in the refactored age filter logic that would cause the search to fail. I've also provided suggestions to improve the formatting and correct typos in the new README.md content.

Comment on lines +93 to +97
const birthyear = age && RangeObject.fromRange(
age.map(x =>
new Date().getFullYear() - x + 1
) as [number, number]
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

연령 범위를 출생 연도 범위로 변환하는 로직에서 .reverse() 호출이 누락되었습니다.

현재 로직은 age[20, 30]과 같을 때 출생 연도 범위를 [2004, 1994]와 같이 잘못된 순서로 생성합니다. 이로 인해 데이터베이스 쿼리가 의도한 대로 동작하지 않아 검색 결과가 비어있게 될 수 있습니다.

기존 search.users.filters.ts 파일에 있던 것처럼 map 호출 후에 .reverse()를 추가하여 [1994, 2004]와 같이 올바른 순서의 배열을 생성해야 합니다.

Suggested change
const birthyear = age && RangeObject.fromRange(
age.map(x =>
new Date().getFullYear() - x + 1
) as [number, number]
);
const birthyear = age && RangeObject.fromRange(
age.map(x =>
new Date().getFullYear() - x + 1
).reverse() as [number, number]
);

Comment thread README.md
Comment on lines +9 to +35
코드를 새로 배포할 수록, 빌드시간이 증가하여 종국에는 이미지 빌드에 23분이나 걸리게 됨 \
또한 api 응답에 걸리는 시간도 10배 이상 증가함

### 관찰 1
image를 새로 빌드할 때마다, CPU & Network 사용량이 급격하게 증가하는 것을 발견

### 해결 1
github action을 이용하여 별도 서버에서 이미지를 빌드하여, docker hub에 올리고 \
프로덕션 서버에서 빌드된 이미지를 pull 해서 쓰는 것으로 변경
-> 빌드시간 3분 이내로 안정화됨, 그러나 api 성능 저하는 해결하지 못함

### 관찰2

``` shell
docker stats
```
명령어를 통해 container의 자원 사용량을 발견
-> 순간 Net/IO, Block/IO 항목이 할당량 보다 많은 자원을 소비하는 것을 알게 됨

### 해결2
t2 micro 크래딧의 한계로 인한 성능저하로 판단하여, unlimited 모드로 설정함 \
unlimited 모드: 자원 사용량이 limit을 초고할 경우 credit을 초과분 만큼 늘리고 후에 초과 사용량 만큼의 금액을 청구하는 방식 \
응답시간 다시 이전과 같은 수준으로 감소함

### 결론
docker를 통해 안정적인 배포를 하려면 t2 micro 보다 높은 사양 서버가 필요 \
규모가 작은 프로젝트라먄 도커를 사용하지 않고 t2 micro에 배포하는 것도 합리적이어 보임

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

안녕하세요, 추가해주신 트러블슈팅 경험 공유 감사합니다. 내용 중 몇 가지 오타와 마크다운 서식에 대한 제안이 있습니다.

  • 오타 수정

    • 30행: 초고할 -> 초과할
    • 35행: 프로젝트라먄 -> 프로젝트라면
  • 마크다운 서식

    • 여러 줄 끝에 있는 \ 문자는 일부 마크다운 렌더러에서 의도치 않게 표시될 수 있습니다. 줄바꿈을 원하신다면 줄 끝에 공백 두 개를 사용하시거나, 문단 구분을 위해 빈 줄을 사용하시는 것이 더 일반적입니다. 가독성을 위해 \를 제거하는 것을 고려해보세요. (해당 라인: 9, 16, 29, 30, 34)

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.

1 participant