AIdeaText commited on
Commit
71433cb
1 Parent(s): 7d3bc93

Update modules/database/semantic_mongo_db.py

Browse files
modules/database/semantic_mongo_db.py CHANGED
@@ -96,7 +96,7 @@ def get_student_semantic_analysis(username, limit=10):
96
  try:
97
  collection = get_collection(COLLECTION_NAME)
98
  if not collection:
99
- logger.error("No se pudo obtener la colección")
100
  return []
101
 
102
  query = {
@@ -108,18 +108,17 @@ def get_student_semantic_analysis(username, limit=10):
108
  projection = {
109
  "timestamp": 1,
110
  "concept_graph": 1,
111
- "_id": 1 # MongoDB siempre incluye el _id a menos que lo excluyas explícitamente
112
  }
113
 
114
- cursor = collection.find(
115
- query,
116
- projection=projection
117
- ).sort("timestamp", -1)
118
 
119
  if limit:
120
  cursor = cursor.limit(limit)
121
-
122
- return list(cursor)
 
 
123
 
124
  except Exception as e:
125
  logger.error(f"Error recuperando análisis semántico: {str(e)}")
 
96
  try:
97
  collection = get_collection(COLLECTION_NAME)
98
  if not collection:
99
+ logger.error("No se pudo obtener la colección semantic")
100
  return []
101
 
102
  query = {
 
108
  projection = {
109
  "timestamp": 1,
110
  "concept_graph": 1,
111
+ "_id": 1
112
  }
113
 
114
+ cursor = collection.find(query, projection).sort("timestamp", -1)
 
 
 
115
 
116
  if limit:
117
  cursor = cursor.limit(limit)
118
+
119
+ result = list(cursor)
120
+ logger.info(f"Recuperados {len(result)} análisis semánticos")
121
+ return result
122
 
123
  except Exception as e:
124
  logger.error(f"Error recuperando análisis semántico: {str(e)}")