v3 / modules /database /current_situation_mongo_db.py
AIdeaText's picture
Update modules/database/current_situation_mongo_db.py
0a09d3c verified
raw
history blame
1.31 kB
# modules/database/current_situation_mongo_db.py
from datetime import datetime, timezone
import logging
from .mongo_db import get_collection, insert_document, find_documents
logger = logging.getLogger(__name__)
COLLECTION_NAME = 'student_current_situation'
# En modules/database/current_situation_mongo_db.py
def store_current_situation_result(username, text, metrics, feedback):
"""
Guarda los resultados del an谩lisis de situaci贸n actual.
"""
try:
collection = get_collection('student_current_situation')
# Crear documento
document = {
'username': username,
'timestamp': datetime.now(timezone.utc).isoformat(),
'text': text,
'metrics': metrics,
'feedback': feedback,
'analysis_type': 'current_situation'
}
# Insertar documento
result = collection.insert_one(document)
if result.inserted_id:
logger.info(f"An谩lisis de situaci贸n actual guardado para {username}")
return True
logger.error("No se pudo insertar el documento")
return False
except Exception as e:
logger.error(f"Error guardando an谩lisis de situaci贸n actual: {str(e)}")
return False