eeshanyaj commited on
Commit
608876c
·
1 Parent(s): 6511736

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 with database connection"""
42
- self.db = get_database()
 
 
 
 
 
43
  self.collection_name = "conversations"
44
  self.retrieval_logs_collection = "retrieval_logs"
45
- print("✅ ConversationRepository initialized with MongoDB")
 
 
 
 
 
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 with database connection"""
18
- self.db = get_database()
19
-
20
- if self.db is None:
21
- print("⚠️ UserRepository: MongoDB not connected")
22
- self.users = None
23
- else:
24
- self.users = self.db["users"]
25
- print("✅ UserRepository initialized")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"""