AIdeaText commited on
Commit
182af1b
1 Parent(s): 957d661

Update modules/database/semantic_mongo_db.py

Browse files
modules/database/semantic_mongo_db.py CHANGED
@@ -93,8 +93,37 @@ def get_student_semantic_analysis(username, limit=10):
93
  Returns:
94
  list: Lista de análisis semánticos
95
  """
96
- query = {"username": username, "analysis_type": "semantic"}
97
- return find_documents(COLLECTION_NAME, query, sort=[("timestamp", -1)], limit=limit)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
  def update_student_semantic_analysis(analysis_id, update_data):
100
  """
 
93
  Returns:
94
  list: Lista de análisis semánticos
95
  """
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 = {
103
+ "username": username,
104
+ "analysis_type": "semantic"
105
+ }
106
+
107
+ # Definir los campos que queremos recuperar
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)}")
126
+ return []
127
 
128
  def update_student_semantic_analysis(analysis_id, update_data):
129
  """