Ali2206 commited on
Commit
8393885
·
verified ·
1 Parent(s): 7aba3e5

Update api/routes.py

Browse files
Files changed (1) hide show
  1. api/routes.py +10 -5
api/routes.py CHANGED
@@ -161,13 +161,18 @@ async def delete_patient(patient_id: str, current_user: dict = Depends(get_curre
161
  @router.get("/patients/count")
162
  async def count_patients(current_user: dict = Depends(get_current_user)):
163
  try:
164
- print("👤 Counting patients for:", current_user["email"])
165
- count = await patients_collection.count_documents({
166
- "created_by": current_user["email"]
167
- })
 
 
 
 
 
168
  return {"count": count}
169
  except Exception as e:
170
- print("❌ Error in count_documents:", str(e))
171
  raise HTTPException(status_code=500, detail="Failed to count patients")
172
 
173
 
 
161
  @router.get("/patients/count")
162
  async def count_patients(current_user: dict = Depends(get_current_user)):
163
  try:
164
+ email = current_user["email"]
165
+ print("🧪 Counting patients for email:", email)
166
+
167
+ filter_query = { "created_by": email }
168
+ print("🔍 Mongo filter:", filter_query)
169
+
170
+ count = await patients_collection.count_documents(filter_query)
171
+ print("✅ Count result:", count)
172
+
173
  return {"count": count}
174
  except Exception as e:
175
+ print("❌ Exception in /patients/count:", repr(e))
176
  raise HTTPException(status_code=500, detail="Failed to count patients")
177
 
178