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:
Tanya
2026-01-05 13:37:45 -05:00
parent 0b95cd2492
commit c69604573d
6 changed files with 59 additions and 8 deletions
+23 -4
View File
@@ -10,6 +10,7 @@ from sqlalchemy import (
Column,
Date,
DateTime,
String,
ForeignKey,
Index,
Integer,
@@ -37,19 +38,37 @@ class PrismaCompatibleDateTime(TypeDecorator):
Prisma's SQLite driver has issues with microseconds in datetime strings.
This type ensures datetimes are stored in ISO format without microseconds:
'YYYY-MM-DD HH:MM:SS' instead of 'YYYY-MM-DD HH:MM:SS.ffffff'
Uses String as the underlying type for SQLite to have full control over the format.
"""
impl = DateTime
impl = String
cache_ok = True
def process_bind_param(self, value, dialect):
"""Convert Python datetime to SQL string format."""
"""Convert Python datetime to SQL string format without microseconds."""
if value is None:
return None
if isinstance(value, datetime):
# Strip microseconds and format as ISO string without microseconds
# This ensures Prisma can read it correctly
value = value.replace(microsecond=0)
return value.strftime('%Y-%m-%d %H:%M:%S')
return value.replace(microsecond=0).strftime('%Y-%m-%d %H:%M:%S')
# If it's already a string, ensure it doesn't have microseconds
if isinstance(value, str):
try:
# Parse and reformat to remove microseconds
if '.' in value:
# Has microseconds or timezone info - strip them
dt = datetime.strptime(value.split('.')[0], '%Y-%m-%d %H:%M:%S')
elif 'T' in value:
# ISO format with T
dt = datetime.fromisoformat(value.replace('Z', '+00:00').split('.')[0])
else:
# Already in correct format
return value
return dt.strftime('%Y-%m-%d %H:%M:%S')
except (ValueError, TypeError):
# If parsing fails, return as-is
return value
return value
def process_result_value(self, value, dialect):