Db interface vehicles CRUD implemented #150
No reviewers
Labels
No labels
CI/CD
MongoDB
PostgreSQL
api
authentication
bug
documentation
duplicate
enhancement
example issue
fix
good first issue
help wanted
high-level requirement
infrastructure
invalid
low-level requirement
medium-level requirement
question
security
test
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
AndreFerreira5/starranja!150
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "db-interface-vehicles-CRUD"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Note: tests passed fine, but with warnings. Not sure if the warnings are relevant or not:
Pull request overview
This PR implements the complete CRUD (Create, Read, Update, Delete) operations for the
VehicleRepoclass, replacingNotImplementedErrorstubs with functional implementations using the Beanie ODM for MongoDB. The implementation enables full vehicle management capabilities in the application, including creating vehicles, retrieving them by various criteria, updating vehicle data, and deleting vehicles from the database.Key Changes
insert(),get(),find_one(),find(),set(),save(),delete()) for database operations💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@ -26,9 +26,13 @@ class VehicleRepo:Raises:Use the
@handle_repo_errorsdecorator instead of manual try-catch blocks for consistency with the codebase pattern. The decorator is available insrc.repository.decoratorsand is used throughoutWorkOrderRepo.Example:
@ -41,9 +45,9 @@ class VehicleRepo:Returns:Vehicle document if found, None otherwiseChange logging level from
logger.infotologger.debugfor read operations. The codebase pattern (seeWorkOrderRepo) useslogger.debugfor retrieval operations and reserveslogger.infofor write operations (create, update, delete).Use the
@handle_repo_errorsdecorator instead of manual try-catch blocks for consistency with the codebase pattern. The decorator is available insrc.repository.decoratorsand is used throughoutWorkOrderRepo.Example:
@ -58,3 +62,3 @@"""logger.info(f"Retrieving vehicle by license plate: {license_plate}")logger.debug(f"Retrieving vehicle by license plate: {license_plate}")Use the
@handle_repo_errorsdecorator instead of manual try-catch blocks for consistency with the codebase pattern. The decorator is available insrc.repository.decoratorsand is used throughoutWorkOrderRepo.Example:
Change logging level from
logger.infotologger.debugfor read operations. The codebase pattern (seeWorkOrderRepo) useslogger.debugfor retrieval operations and reserveslogger.infofor write operations (create, update, delete).@ -76,3 +80,3 @@raise NotImplementedError("get_by_client_id method not yet implemented")return await Vehicle.find(Vehicle.client_id == client_id).to_list()@handle_repo_errors("update_vehicle")Change logging level from
logger.infotologger.debugfor read operations. The codebase pattern (seeWorkOrderRepo) useslogger.debugfor retrieval operations and reserveslogger.infofor write operations (create, update, delete).Use the
@handle_repo_errorsdecorator instead of manual try-catch blocks for consistency with the codebase pattern. The decorator is available insrc.repository.decoratorsand is used throughoutWorkOrderRepo.Example:
@ -93,0 +98,4 @@return Noneupdate_dict = update_data.model_dump(by_alias=True, exclude_unset=True)[nitpick] The
if update_dict:check is inconsistent with the pattern inWorkOrderRepo.update()(lines 245-249), which always callsset()andsave()regardless of whether the update dictionary is empty. This means that with an empty update,WorkOrderRepowill still update theupdated_attimestamp, whileVehicleRepowon't.Consider removing this check for consistency, or explicitly document the intended behavior when update_data has no fields set.
Use the
@handle_repo_errorsdecorator instead of manual try-catch blocks for consistency with the codebase pattern. The decorator is available insrc.repository.decoratorsand is used throughoutWorkOrderRepo.Example:
Use the
@handle_repo_errorsdecorator instead of manual try-catch blocks for consistency with the codebase pattern. The decorator is available insrc.repository.decoratorsand is used throughoutWorkOrderRepo.Example:
You should follow the copilot review. The main focus is the @handle_repo_errorsand the logger.debug
Fix that and the this PR is going ready to be merged
@ -26,9 +26,13 @@ class VehicleRepo:Raises:Copilot is correct, you should use @handle_repo_errors to match the codebase pattern. Follow the example of another repository, like workOrders, to get an ideia.
@ -41,9 +45,9 @@ class VehicleRepo:Returns:Vehicle document if found, None otherwiseCopilot is correct.
Same situation as before, use @handle_repo_errors.
@vascodias23 you still have requested changes to do, please go ahead and do it so we can advance with the development