feat: Improve face identification process with validation and error handling
This commit enhances the face identification process by adding validation checks for person ID and names, ensuring that users provide necessary information before proceeding. It also introduces detailed logging for better debugging and user feedback during the identification process. Additionally, error handling is improved to provide user-friendly messages in case of failures, enhancing the overall user experience.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, status
|
||||
from fastapi.responses import FileResponse, Response
|
||||
from rq import Queue
|
||||
@@ -306,12 +308,14 @@ def identify_face(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail="first_name and last_name are required to create a person",
|
||||
)
|
||||
# Explicitly set created_date to ensure it's a valid datetime object
|
||||
person = Person(
|
||||
first_name=first_name,
|
||||
last_name=last_name,
|
||||
middle_name=middle_name,
|
||||
maiden_name=maiden_name,
|
||||
date_of_birth=request.date_of_birth,
|
||||
created_date=datetime.utcnow(),
|
||||
)
|
||||
db.add(person)
|
||||
db.flush() # get person.id
|
||||
|
||||
Reference in New Issue
Block a user