-
Notifications
You must be signed in to change notification settings - Fork 0
fix(MAJORLEA-001): 3 review findings in HiringController.java #72
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,16 @@ | ||
| package cx.flamingo.analysis.controller; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| import cx.flamingo.analysis.model.JobOpening; | ||
| import cx.flamingo.analysis.model.ApiResponse; | ||
| import cx.flamingo.analysis.service.CacheService; | ||
| import cx.flamingo.analysis.service.HiringService; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
|
|
@@ -18,19 +20,23 @@ | |
| public class HiringController { | ||
|
|
||
| private final HiringService hiringService; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ HiringController endpoints do not guard with cacheService.isCacheReady() Added π€ Prompt for AI agentsfix confidence: π‘ 75 medium β react π/π to teach the reviewer |
||
| private final CacheService cacheService; | ||
|
|
||
| @GetMapping("/manager") | ||
| public Map<String, Object> getHiringManagerProfile() { | ||
| return hiringService.getHiringManagerProfile(); | ||
| public ResponseEntity<ApiResponse<Map<String, Object>>> getHiringManagerProfile() { | ||
| if (!cacheService.isCacheReady()) { | ||
| return ResponseEntity.ok(ApiResponse.error("Cache is not ready yet, please try again later")); | ||
| } | ||
| Map<String, Object> profile = hiringService.getHiringManagerProfile(); | ||
| return ResponseEntity.ok(ApiResponse.success("Hiring manager profile retrieved successfully", profile)); | ||
| } | ||
|
|
||
| @GetMapping("/jobs") | ||
| public Map<String, Object> getJobOpenings() { | ||
| Map<String, Object> response = new HashMap<>(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ HiringController.getJobOpenings() manually constructs envelope map instead of using ApiResponse factory methods In π€ Prompt for AI agentsfix confidence: π‘ 82 medium β react π/π to teach the reviewer |
||
| public ResponseEntity<ApiResponse<List<JobOpening>>> getJobOpenings() { | ||
| if (!cacheService.isCacheReady()) { | ||
| return ResponseEntity.ok(ApiResponse.error("Cache is not ready yet, please try again later")); | ||
| } | ||
| List<JobOpening> jobs = hiringService.getJobOpenings(); | ||
| response.put("status", "success"); | ||
| response.put("message", "Job openings retrieved successfully"); | ||
| response.put("data", jobs); | ||
| return response; | ||
| return ResponseEntity.ok(ApiResponse.success("Job openings retrieved successfully", jobs)); | ||
| } | ||
| } | ||
| } | ||
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.
𦩠π΄ HiringController.getHiringManagerProfile() returns raw Map instead of ApiResponse envelope
In
getHiringManagerProfile(): changed return type fromMap<String, Object>toResponseEntity<ApiResponse<Map<String, Object>>>, addedcacheService.isCacheReady()guard returningApiResponse.error(...)when not ready, and wrapped the service result withApiResponse.success(...). Added imports forResponseEntity,ApiResponse, andCacheService. AddedcacheServicefield. Risk: assumesApiResponseclass exists atcx.flamingo.analysis.model.ApiResponsewithsuccess(String, T)anderror(String)static factory methods β reviewer should verify the exact package and method signatures match the codebase.π€ Prompt for AI agents
fix confidence: π‘ 82 medium β react π/π to teach the reviewer