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] 유저 이름으로 이력서 조회 로직 수정 #300

Merged
merged 3 commits into from
Mar 8, 2025

Conversation

lsh1215
Copy link
Member

@lsh1215 lsh1215 commented Mar 7, 2025

변경 사항

  • URL 인코딩 문제
    확인결과 Swagger에서만 발생하는 것으로 확인(실제로는 인코딩된 데이터를 넣지 않아도 됨)

유저 이름으로 이력서 조회 로직에서 userService.getLoginUser() 함수가 안쓰이는데 들어가 있었음
이로 인해, UserDetail 문제 발생 -> 코드 제거

  • 유저 이름 일부로 이력서 조회
    유저 이름 일부로도 이력서 조회 가능하도록 수정

테스트 결과 (테스트를 했으면)

swagger(url 인코딩 자동)

image

postman 테스트

image

유저 이름 일부로 이력서 조회

image

Summary by CodeRabbit

  • New Features

    • Enhanced resume search functionality now supports partial username queries for more flexible results.
    • Adjusted access rules allow improved GET request handling on search endpoints.
  • Documentation

    • API details have been updated for clearer parameter descriptions during resume search.

@lsh1215 lsh1215 self-assigned this Mar 7, 2025
@lsh1215 lsh1215 linked an issue Mar 7, 2025 that may be closed by this pull request
Copy link

coderabbitai bot commented Mar 7, 2025

Walkthrough

This 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

File(s) Change Summary
backend/.../api/resume/controller/ResumeController.java,
backend/.../api/resume/repository/ResumeRepository.java,
backend/.../api/resume/service/ResumeService.java
Enhanced resume search:
- Controller: Added Swagger @parameter annotation and updated method call to use partial search.
- Repository: Added findByUserNameContaining using SQL LIKE for partial matches.
- Service: Introduced searchResumesByUserNameContaining that invokes the new repository method.
backend/.../global/config/SecurityConfig.java Updated security configuration:
- Reformatting of allowed origins for clarity.
- Modified endpoint permissions, now allowing GET requests on /api/v1/resumes/search/** and removing non-GET access to /api/v1/resumes/search.

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

Possibly related PRs

  • 이력서 조회순 정렬 기능 추가 #281: Modifies the ResumeController to support enhanced resume retrieval functionality, including sorting by view count, which relates to the updated search capabilities introduced in this PR.

Suggested reviewers

  • dlwldnjs1009
  • Gwanghyeon-k
  • YunJuwon0825

Poem

I'm a quick little bunny, coding all day,
Hopping through endpoints in a techie ballet.
Partial matches bloom like carrots in the sun,
Secure paths and clear docs make the work fun.
With every hop, my joy grows a bit more—
Cheers to fresh changes that we all adore! 🐰


📜 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 9c99a9f and 9b41669.

📒 Files selected for processing (4)
  • backend/src/main/java/com/techeer/backend/api/resume/controller/ResumeController.java (2 hunks)
  • backend/src/main/java/com/techeer/backend/api/resume/repository/ResumeRepository.java (1 hunks)
  • backend/src/main/java/com/techeer/backend/api/resume/service/ResumeService.java (1 hunks)
  • backend/src/main/java/com/techeer/backend/global/config/SecurityConfig.java (3 hunks)
🔇 Additional comments (5)
backend/src/main/java/com/techeer/backend/api/resume/repository/ResumeRepository.java (1)

23-24: Well-implemented LIKE query for partial username matching!

The implementation of findByUserNameContaining using a SQL LIKE clause with wildcards on both sides is a good approach for enabling partial matching of usernames. This will allow finding resumes even when only part of a username is provided.

backend/src/main/java/com/techeer/backend/api/resume/service/ResumeService.java (1)

46-49: Good service method implementation with clear documentation.

The new service method provides a clean implementation with a descriptive comment that clearly explains its purpose. The method properly delegates to the repository layer, following the established pattern in the service.

backend/src/main/java/com/techeer/backend/global/config/SecurityConfig.java (2)

44-46: Improved code formatting for readability.

The reformatting of the setAllowedOrigins method call improves readability while maintaining the same functionality.


74-76: Security configuration updated to support partial username search.

The updated security configuration now includes the wildcard pattern /api/v1/resumes/search/** which is necessary to allow GET requests for the new partial username search functionality.

backend/src/main/java/com/techeer/backend/api/resume/controller/ResumeController.java (1)

80-84: Enhanced API with partial username search and improved Swagger documentation.

The controller now uses the new service method for partial username matching, addressing the URL encoding issue mentioned in the PR objectives. The addition of Swagger annotations improves API documentation for client developers.

One suggestion: Consider updating the method operation summary to reflect that it now supports partial matching:

-@Operation(summary = "회원 이름으로 이력서 조회")
+@Operation(summary = "회원 이름 전체 또는 일부로 이력서 조회")
✨ Finishing Touches
  • 📝 Generate Docstrings

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

@github-actions github-actions bot left a 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, '%')")
Copy link
Contributor

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

Copy link
Member Author

@lsh1215 lsh1215 Mar 8, 2025

Choose a reason for hiding this comment

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

궁금한 점이 두가지 있습니다.

  1. username% 와 같이 정렬 기준에 부합하는 방식으로 조회하지 않으면 인덱스 성능이 안 나온다고 이해했는데 맞는지
  2. 그렇다면 username%과 같은 방식으로 밖에 like 조회가 안되는건데 성능을 위해 기능을 버려야 하나?
  3. 이런 경우에 fulltext search를 이용하는건지

이런 생각이 들었는데, 맞는지 궁금합니다

Copy link
Collaborator

@jung2941 jung2941 left a comment

Choose a reason for hiding this comment

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

테스트 테스트

@lsh1215 lsh1215 merged commit 6539896 into develop Mar 8, 2025
4 checks passed
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.

[fix] 유저 이름으로 이력서 조회 기능 수정
3 participants