Spaces:
Sleeping
Sleeping
small comments added
Browse files
app/db/repositories/conversation_repository.py
CHANGED
|
@@ -38,11 +38,21 @@ class ConversationRepository:
|
|
| 38 |
"""
|
| 39 |
|
| 40 |
def __init__(self):
|
| 41 |
-
"""Initialize repository
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
self.collection_name = "conversations"
|
| 44 |
self.retrieval_logs_collection = "retrieval_logs"
|
| 45 |
-
print("✅ ConversationRepository initialized
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
@property
|
| 48 |
def collection(self):
|
|
|
|
| 38 |
"""
|
| 39 |
|
| 40 |
def __init__(self):
|
| 41 |
+
"""Initialize repository - database connection is fetched dynamically"""
|
| 42 |
+
# """Initialize repository with database connection"""
|
| 43 |
+
# self.db = get_database()
|
| 44 |
+
# self.collection_name = "conversations"
|
| 45 |
+
# self.retrieval_logs_collection = "retrieval_logs"
|
| 46 |
+
# print("✅ ConversationRepository initialized with MongoDB")
|
| 47 |
+
|
| 48 |
self.collection_name = "conversations"
|
| 49 |
self.retrieval_logs_collection = "retrieval_logs"
|
| 50 |
+
print("✅ ConversationRepository initialized")
|
| 51 |
+
|
| 52 |
+
@property
|
| 53 |
+
def db(self):
|
| 54 |
+
"""Get database connection dynamically"""
|
| 55 |
+
return get_database()
|
| 56 |
|
| 57 |
@property
|
| 58 |
def collection(self):
|
app/db/repositories/user_repository.py
CHANGED
|
@@ -14,15 +14,31 @@ class UserRepository:
|
|
| 14 |
"""Repository for user data in MongoDB"""
|
| 15 |
|
| 16 |
def __init__(self):
|
| 17 |
-
"""Initialize repository
|
| 18 |
-
self.
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
def _check_connection(self):
|
| 28 |
"""Check if MongoDB is connected"""
|
|
|
|
| 14 |
"""Repository for user data in MongoDB"""
|
| 15 |
|
| 16 |
def __init__(self):
|
| 17 |
+
"""Initialize repository - database connection is fetched dynamically"""
|
| 18 |
+
self.collection_name = "users"
|
| 19 |
+
# """Initialize repository with database connection"""
|
| 20 |
+
# self.db = get_database()
|
| 21 |
+
|
| 22 |
+
# if self.db is None:
|
| 23 |
+
# print("⚠️ UserRepository: MongoDB not connected")
|
| 24 |
+
# self.users = None
|
| 25 |
+
# else:
|
| 26 |
+
# self.users = self.db["users"]
|
| 27 |
+
# print("✅ UserRepository initialized")
|
| 28 |
+
print("✅ UserRepository initialized")
|
| 29 |
+
|
| 30 |
+
@property
|
| 31 |
+
def db(self):
|
| 32 |
+
"""Get database connection dynamically"""
|
| 33 |
+
return get_database()
|
| 34 |
+
|
| 35 |
+
@property
|
| 36 |
+
def users(self):
|
| 37 |
+
"""Get users collection"""
|
| 38 |
+
db = self.db
|
| 39 |
+
if db is None:
|
| 40 |
+
return None
|
| 41 |
+
return db[self.collection_name]
|
| 42 |
|
| 43 |
def _check_connection(self):
|
| 44 |
"""Check if MongoDB is connected"""
|