Spaces:
Sleeping
Sleeping
Update modules/database/discourse_mongo_db.py
Browse files
modules/database/discourse_mongo_db.py
CHANGED
|
@@ -89,6 +89,11 @@ def store_student_discourse_result(username, text1, text2, analysis_result):
|
|
| 89 |
logger.error(f"Error al guardar el análisis del discurso: {str(e)}")
|
| 90 |
return False
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
def get_student_discourse_analysis(username, limit=10):
|
| 93 |
"""
|
| 94 |
Recupera los análisis del discurso de un estudiante.
|
|
@@ -101,7 +106,7 @@ def get_student_discourse_analysis(username, limit=10):
|
|
| 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 = {
|
|
@@ -116,19 +121,22 @@ def get_student_discourse_analysis(username, limit=10):
|
|
| 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 |
-
|
|
|
|
|
|
|
| 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.
|
|
|
|
| 89 |
logger.error(f"Error al guardar el análisis del discurso: {str(e)}")
|
| 90 |
return False
|
| 91 |
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
|
| 97 |
def get_student_discourse_analysis(username, limit=10):
|
| 98 |
"""
|
| 99 |
Recupera los análisis del discurso de un estudiante.
|
|
|
|
| 106 |
try:
|
| 107 |
collection = get_collection(COLLECTION_NAME)
|
| 108 |
if not collection:
|
| 109 |
+
logger.error("No se pudo obtener la colección discourse")
|
| 110 |
return []
|
| 111 |
|
| 112 |
query = {
|
|
|
|
| 121 |
"_id": 1
|
| 122 |
}
|
| 123 |
|
| 124 |
+
cursor = collection.find(query, projection).sort("timestamp", -1)
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
if limit:
|
| 127 |
cursor = cursor.limit(limit)
|
| 128 |
+
|
| 129 |
+
result = list(cursor)
|
| 130 |
+
logger.info(f"Recuperados {len(result)} análisis del discurso")
|
| 131 |
+
return result
|
| 132 |
|
| 133 |
except Exception as e:
|
| 134 |
logger.error(f"Error recuperando análisis del discurso: {str(e)}")
|
| 135 |
return []
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
|
| 140 |
def get_student_discourse_data(username):
|
| 141 |
"""
|
| 142 |
Obtiene un resumen de los análisis del discurso de un estudiante.
|