-
Notifications
You must be signed in to change notification settings - Fork 4
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
[Sweep Rules] Refactor searchRegions function in regionController.js #156
Conversation
Rollback Files For Sweep
|
Sandbox Executions
Check backend/src/utils/queryBuilder.js with contents:
Check backend/src/utils/queryExecutor.js with contents:
Check backend/src/controllers/regionController.js with contents: |
Important Auto Review SkippedBot user detected. To trigger a single review, invoke the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ? TipsChat with CodeRabbit Bot (
|
The command: ✖ 3 problems (3 errors, 0 warnings) ##[error]Process completed with exit code 1.`
|
🚀 Wrote ChangesDone. |
PR Feedback (click)
I created this PR to address this rule:
"Refactor large functions to be more modular."
Description
This PR refactors the
searchRegions
function inregionController.js
to improve modularity and maintainability. The function is currently responsible for handling the entire search functionality, including constructing the SQL query, executing the query, and processing the results. The refactoring breaks down the function into smaller, more modular functions that handle specific tasks, such as constructing the SQL query and executing the query.Summary of Changes
queryBuilder.js
inbackend/src/utils
to handle the construction of the SQL query.queryExecutor.js
inbackend/src/utils
to handle the execution of the SQL query and retrieval of search results.searchRegions
function inregionController.js
to call the new functions fromqueryBuilder.js
andqueryExecutor.js
and process the search results.Changes Made
queryBuilder.js
to handle the construction of the SQL query. ThebuildQuery
function takesqueryTerms
andhierarchyId
as parameters and constructs the SQL query based on the input.queryExecutor.js
to handle the execution of the SQL query and retrieval of search results. TheexecuteQuery
function takessqlQuery
andreplacements
as parameters and executes the SQL query usingsequelize.query
.searchRegions
function inregionController.js
to remove the code for constructing the SQL query and executing the query. Instead, it calls thebuildQuery
function fromqueryBuilder.js
to construct the SQL query and theexecuteQuery
function fromqueryExecutor.js
to execute the query and retrieve the search results.Testing
queryBuilder.js
andqueryExecutor.js
.searchRegions
function.Related Issue
Link to the related issue