AIdeaText commited on
Commit
4c94a50
verified
1 Parent(s): cd3b909

Update modules/database/current_situation_mongo_db.py

Browse files
modules/database/current_situation_mongo_db.py CHANGED
@@ -92,6 +92,31 @@ def verify_storage(username):
92
  logger.error(f"Error verificando almacenamiento: {str(e)}")
93
  return False
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  def get_recent_situation_analysis(username, limit=5):
96
  """
97
  Obtiene los an谩lisis m谩s recientes de un usuario.
 
92
  logger.error(f"Error verificando almacenamiento: {str(e)}")
93
  return False
94
 
95
+ def get_current_situation_analysis(username, limit=5):
96
+ """
97
+ Obtiene los an谩lisis de situaci贸n actual de un usuario.
98
+ """
99
+ try:
100
+ collection = get_collection(COLLECTION_NAME)
101
+ if collection is None:
102
+ logger.error("No se pudo obtener la colecci贸n")
103
+ return []
104
+
105
+ # Buscar documentos
106
+ query = {'username': username, 'analysis_type': 'current_situation'}
107
+ cursor = collection.find(query).sort('timestamp', -1)
108
+
109
+ # Aplicar l铆mite si se especifica
110
+ if limit:
111
+ cursor = cursor.limit(limit)
112
+
113
+ # Convertir cursor a lista
114
+ return list(cursor)
115
+
116
+ except Exception as e:
117
+ logger.error(f"Error obteniendo an谩lisis de situaci贸n actual: {str(e)}")
118
+ return []
119
+
120
  def get_recent_situation_analysis(username, limit=5):
121
  """
122
  Obtiene los an谩lisis m谩s recientes de un usuario.