-
Notifications
You must be signed in to change notification settings - Fork 0
fix(MAJORLEA-002): 5 review findings across 3 files #75
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,6 +1,5 @@ | ||
| package cx.flamingo.analysis.controller; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.web.bind.annotation.GetMapping; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
|
|
@@ -12,35 +11,33 @@ | |
| import cx.flamingo.analysis.model.Region; | ||
| import cx.flamingo.analysis.model.SoccerTeam; | ||
| import cx.flamingo.analysis.model.State; | ||
| import cx.flamingo.analysis.service.CacheService; | ||
| import cx.flamingo.analysis.service.CityService; | ||
| import cx.flamingo.analysis.service.LanguageService; | ||
| import cx.flamingo.analysis.service.RegionService; | ||
| import cx.flamingo.analysis.service.SoccerTeamService; | ||
| import cx.flamingo.analysis.service.StateService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| @Slf4j | ||
| @RestController | ||
|
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. 𦩠π΄ EntityController uses @Autowired field injection instead of @requiredargsconstructor constructor injection Replaced all five π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| @RequestMapping("/api/entities") | ||
| @RequiredArgsConstructor | ||
| public class EntityController { | ||
|
|
||
| @Autowired | ||
| private CityService cityService; | ||
|
|
||
| @Autowired | ||
| private RegionService regionService; | ||
|
|
||
| @Autowired | ||
| private StateService stateService; | ||
|
|
||
| @Autowired | ||
| private LanguageService languageService; | ||
|
|
||
| @Autowired | ||
|
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. 𦩠π΄ EntityController endpoints do not check isCacheReady() before serving data Added π€ Prompt for AI agentsfix confidence: π‘ 72 medium β react π/π to teach the reviewer |
||
| private SoccerTeamService soccerTeamService; | ||
| private final CacheService cacheService; | ||
| private final CityService cityService; | ||
| private final RegionService regionService; | ||
| private final StateService stateService; | ||
| private final LanguageService languageService; | ||
| private final SoccerTeamService soccerTeamService; | ||
|
|
||
| @GetMapping("/cities/{id}") | ||
| public ApiResponse<City> getCityById(@PathVariable String id) { | ||
| if (!cacheService.isCacheReady()) { | ||
| return ApiResponse.error("Cache is not ready"); | ||
| } | ||
| City city = cityService.getCityById(id); | ||
| if (city == null) { | ||
| log.warn("City not found with ID: {}", id); | ||
|
|
@@ -51,6 +48,9 @@ public ApiResponse<City> getCityById(@PathVariable String id) { | |
|
|
||
| @GetMapping("/regions/{id}") | ||
| public ApiResponse<Region> getRegionById(@PathVariable String id) { | ||
| if (!cacheService.isCacheReady()) { | ||
| return ApiResponse.error("Cache is not ready"); | ||
| } | ||
| Region region = regionService.getRegionById(id); | ||
| if (region == null) { | ||
| log.warn("Region not found with ID: {}", id); | ||
|
|
@@ -61,6 +61,9 @@ public ApiResponse<Region> getRegionById(@PathVariable String id) { | |
|
|
||
| @GetMapping("/states/{id}") | ||
| public ApiResponse<State> getStateById(@PathVariable String id) { | ||
| if (!cacheService.isCacheReady()) { | ||
| return ApiResponse.error("Cache is not ready"); | ||
| } | ||
| State state = stateService.getStateById(id); | ||
| if (state == null) { | ||
| log.warn("State not found with ID: {}", id); | ||
|
|
@@ -71,6 +74,9 @@ public ApiResponse<State> getStateById(@PathVariable String id) { | |
|
|
||
| @GetMapping("/languages/{id}") | ||
| public ApiResponse<Language> getLanguageById(@PathVariable String id) { | ||
| if (!cacheService.isCacheReady()) { | ||
| return ApiResponse.error("Cache is not ready"); | ||
| } | ||
| Language language = languageService.getLanguageById(id); | ||
| if (language == null) { | ||
| log.warn("Language not found with ID: {}", id); | ||
|
|
@@ -81,11 +87,14 @@ public ApiResponse<Language> getLanguageById(@PathVariable String id) { | |
|
|
||
| @GetMapping("/teams/{id}") | ||
| public ApiResponse<SoccerTeam> getTeamById(@PathVariable String id) { | ||
| if (!cacheService.isCacheReady()) { | ||
| return ApiResponse.error("Cache is not ready"); | ||
| } | ||
| SoccerTeam team = soccerTeamService.getTeamById(id); | ||
| if (team == null) { | ||
| log.warn("Team not found with ID: {}", id); | ||
| return ApiResponse.error(String.format("Team not found with ID: %s", id)); | ||
| } | ||
| return ApiResponse.success(team, String.format("Found team: %s", team.getName())); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,11 @@ public class HiringService { | |
|
|
||
| public Map<String, Object> getHiringManagerProfile() { | ||
| Map<String, Object> response = new HashMap<>(); | ||
| if (!cacheService.isCacheReady()) { | ||
| response.put("status", "error"); | ||
| response.put("message", "Cache is not ready yet, please try again later"); | ||
| return response; | ||
| } | ||
| HiringManagerProfile profile = cacheService.get(CACHE_PATH, PROFILE_KEY, new TypeToken<HiringManagerProfile>() { | ||
| }, refreshInterval) | ||
| .orElseGet(() -> { | ||
|
Comment on lines
36
to
46
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. 𦩠π΄ HiringService endpoints do not guard with isCacheReady() before serving data Added π€ Prompt for AI agentsfix confidence: π‘ 72 medium β react π/π to teach the reviewer |
||
|
|
@@ -65,31 +70,15 @@ public Map<String, Object> getHiringManagerProfile() { | |
| } | ||
|
|
||
| public List<JobOpening> getJobOpenings() { | ||
| if (!cacheService.isCacheReady()) { | ||
| return List.of(); | ||
| } | ||
| return cacheService.get(CACHE_PATH, JOBS_KEY, new TypeToken<List<JobOpening>>() { | ||
| }, refreshInterval) | ||
| .orElseGet(() -> { | ||
| List<JobOpening> jobs = linkedInService.getCompanyJobPostings(); | ||
| if (jobs == null || jobs.isEmpty()) { | ||
| // Fallback to default jobs if LinkedIn API fails | ||
| jobs = List.of( | ||
| JobOpening.builder() | ||
| .id("senior-back-end-engineer-1") | ||
| .title("Senior Back-end Engineer") | ||
| .location("Remote") | ||
| .url("https://djinni.co/jobs/717621-senior-back-end-engineer/") | ||
| .build(), | ||
|
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. 𦩠π HiringService.getJobOpenings() falls back to hardcoded job URLs (djinni.co) when LinkedIn API fails β stale fallback data Removed the hardcoded fallback job postings (three djinni.co URLs) in π€ Prompt for AI agentsfix confidence: π‘ 82 medium β react π/π to teach the reviewer |
||
| JobOpening.builder() | ||
| .id("senior-devops-engineer-2") | ||
| .title("Senior DevOps Engineer") | ||
| .location("Remote") | ||
| .url("https://djinni.co/jobs/717622-senior-devops-engineer/") | ||
| .build(), | ||
| JobOpening.builder() | ||
| .id("senior-front-end-engineer-3") | ||
| .title("Senior Front-end Engineer") | ||
| .location("Remote") | ||
| .url("https://djinni.co/jobs/717624-senior-front-end-engineer/") | ||
| .build()); | ||
| jobs = List.of(); | ||
| } | ||
| cacheService.put(CACHE_PATH, JOBS_KEY, jobs); | ||
| return 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.
𦩠π΄ AutocompleteController endpoints do not check isCacheReady() before serving data
Added
CacheService cacheServiceas an injected field (via@RequiredArgsConstructor, so it must be afinalfield β added at line 30) and importedcx.flamingo.analysis.service.CacheService. In all five endpoint methods (autocompleteCities,autocompleteRegions,autocompleteStates,autocompleteLanguages,autocompleteTeams), insertedif (!cacheService.isCacheReady()) { return ApiResponse.error("Service is not ready yet, please try again later"); }as the very first statement, before thelog.infocall. The check is placed before any service call in each method, satisfying MAJORLEA-002. Confidence is not higher because: (a) the exact class nameCacheServiceand its package are inferred from convention β if the actual class name or package differs, the import will fail to compile; (b) the exact signature ofApiResponse.error(String)is assumed from the finding's description β if the method signature differs (e.g., requires a type parameter or different arguments), a compile error will result. A reviewer should verify bothCacheServiceandApiResponse.errorsignatures against the actual source files.π€ Prompt for AI agents
fix confidence: π‘ 72 medium β react π/π to teach the reviewer