Spaces:
Sleeping
Sleeping
Update modules/database/discourse_mongo_db.py
Browse files
modules/database/discourse_mongo_db.py
CHANGED
|
@@ -92,17 +92,43 @@ def store_student_discourse_result(username, text1, text2, analysis_result):
|
|
| 92 |
def get_student_discourse_analysis(username, limit=10):
|
| 93 |
"""
|
| 94 |
Recupera los análisis del discurso de un estudiante.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
"""
|
| 96 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
query = {
|
| 98 |
"username": username,
|
| 99 |
"analysis_type": "discourse"
|
| 100 |
}
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
except Exception as e:
|
| 103 |
-
logger.error(f"Error
|
| 104 |
return []
|
| 105 |
-
|
| 106 |
def get_student_discourse_data(username):
|
| 107 |
"""
|
| 108 |
Obtiene un resumen de los análisis del discurso de un estudiante.
|
|
|
|
| 92 |
def get_student_discourse_analysis(username, limit=10):
|
| 93 |
"""
|
| 94 |
Recupera los análisis del discurso de un estudiante.
|
| 95 |
+
Args:
|
| 96 |
+
username: Nombre del usuario
|
| 97 |
+
limit: Número máximo de análisis a retornar
|
| 98 |
+
Returns:
|
| 99 |
+
list: Lista de análisis del discurso
|
| 100 |
"""
|
| 101 |
try:
|
| 102 |
+
collection = get_collection(COLLECTION_NAME)
|
| 103 |
+
if not collection:
|
| 104 |
+
logger.error("No se pudo obtener la colección")
|
| 105 |
+
return []
|
| 106 |
+
|
| 107 |
query = {
|
| 108 |
"username": username,
|
| 109 |
"analysis_type": "discourse"
|
| 110 |
}
|
| 111 |
+
|
| 112 |
+
# Definir los campos que queremos recuperar
|
| 113 |
+
projection = {
|
| 114 |
+
"timestamp": 1,
|
| 115 |
+
"combined_graph": 1,
|
| 116 |
+
"_id": 1
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
cursor = collection.find(
|
| 120 |
+
query,
|
| 121 |
+
projection=projection
|
| 122 |
+
).sort("timestamp", -1)
|
| 123 |
+
|
| 124 |
+
if limit:
|
| 125 |
+
cursor = cursor.limit(limit)
|
| 126 |
+
|
| 127 |
+
return list(cursor)
|
| 128 |
+
|
| 129 |
except Exception as e:
|
| 130 |
+
logger.error(f"Error recuperando análisis del discurso: {str(e)}")
|
| 131 |
return []
|
|
|
|
| 132 |
def get_student_discourse_data(username):
|
| 133 |
"""
|
| 134 |
Obtiene un resumen de los análisis del discurso de un estudiante.
|