-
Notifications
You must be signed in to change notification settings - Fork 0
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] 유저 이름으로 이력서 조회 로직 수정 #300
Conversation
WalkthroughThis pull request enhances the resume search functionality by updating the API to support partial username matching. The controller method now uses a new service method that leverages a repository query with a SQL LIKE clause. Additionally, minor formatting improvements were made to the CORS setup and security endpoint permissions, allowing GET requests on a broader search pattern while removing specific non-GET allowances. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant C as ResumeController
participant S as ResumeService
participant R as ResumeRepository
U->>C: Call searchResumesByUserName(user_name)
C->>S: searchResumesByUserNameContaining(user_name)
S->>R: findByUserNameContaining(user_name)
R-->>S: List<Resume>
S-->>C: List<ResumeResponse>
C-->>U: CommonResponse<List<ResumeResponse>
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🔇 Additional comments (5)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review by ChatGPT
@@ -20,6 +20,9 @@ public interface ResumeRepository extends JpaRepository<Resume, Long>, ResumeRep | |||
@Query("SELECT r FROM Resume r WHERE r.user.username = :username") | |||
List<Resume> findResumesByUsername(@Param("username") String username); | |||
|
|||
@Query("SELECT r FROM Resume r WHERE r.user.username LIKE CONCAT('%', :username, '%')") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기 쿼리가 %username%인거로 보여.
그러면 username에 인덱스 걸어도 인덱스 성능이 안나와. 이유는 MySQL innodb 기준으로 데이터를 생성할때 기본적으로 PK에 기본 인덱스가 걸려서 생성돼. 이 경우 pk 기준으로 정렬이 되거든. 결국 인덱스는 데이터의 정렬이 이루어진 후에 검색을 해서 기존 정렬을 하지 않은 데이터 구조보다 탐색이 빨라지는거거든.
아래 링크 참고하면 좋을듯
https://k3068.tistory.com/m/106
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
궁금한 점이 두가지 있습니다.
- username% 와 같이 정렬 기준에 부합하는 방식으로 조회하지 않으면 인덱스 성능이 안 나온다고 이해했는데 맞는지
- 그렇다면 username%과 같은 방식으로 밖에 like 조회가 안되는건데 성능을 위해 기능을 버려야 하나?
- 이런 경우에 fulltext search를 이용하는건지
이런 생각이 들었는데, 맞는지 궁금합니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트 테스트
변경 사항
확인결과 Swagger에서만 발생하는 것으로 확인(실제로는 인코딩된 데이터를 넣지 않아도 됨)
유저 이름으로 이력서 조회 로직에서 userService.getLoginUser() 함수가 안쓰이는데 들어가 있었음
이로 인해, UserDetail 문제 발생 -> 코드 제거
유저 이름 일부로도 이력서 조회 가능하도록 수정
테스트 결과 (테스트를 했으면)
swagger(url 인코딩 자동)
postman 테스트
유저 이름 일부로 이력서 조회
Summary by CodeRabbit
New Features
Documentation