fix#66
Conversation
There was a problem hiding this comment.
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
agerange query parameter into abirthyearrange for user search has been moved from a global interceptor to theUsersController'ssearchAdjacentUsersmethod. This centralizes the age conversion directly where the search request is handled. - API Query Parameter Update: The
SearchAdjacentUsersQueryDTO now explicitly accepts an optionalagerange parameter, simplifying the query structure and making the API contract clearer for age-based filtering. - Endpoint Renaming: The
/api/users/subscriptionsendpoint has been renamed to/api/users/search/subscriptionsto 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
-
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. ↩
There was a problem hiding this comment.
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.
| const birthyear = age && RangeObject.fromRange( | ||
| age.map(x => | ||
| new Date().getFullYear() - x + 1 | ||
| ) as [number, number] | ||
| ); |
There was a problem hiding this comment.
연령 범위를 출생 연도 범위로 변환하는 로직에서 .reverse() 호출이 누락되었습니다.
현재 로직은 age가 [20, 30]과 같을 때 출생 연도 범위를 [2004, 1994]와 같이 잘못된 순서로 생성합니다. 이로 인해 데이터베이스 쿼리가 의도한 대로 동작하지 않아 검색 결과가 비어있게 될 수 있습니다.
기존 search.users.filters.ts 파일에 있던 것처럼 map 호출 후에 .reverse()를 추가하여 [1994, 2004]와 같이 올바른 순서의 배열을 생성해야 합니다.
| 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] | |
| ); |
| 코드를 새로 배포할 수록, 빌드시간이 증가하여 종국에는 이미지 빌드에 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에 배포하는 것도 합리적이어 보임 |
There was a problem hiding this comment.
유저 검색시 발생하는 오류 해결