Abhinav777-77 commited on
Commit
ac29b9f
·
verified ·
1 Parent(s): 46ba9b4

Update backend/src/routes/case_routes.py

Browse files
Files changed (1) hide show
  1. backend/src/routes/case_routes.py +11 -7
backend/src/routes/case_routes.py CHANGED
@@ -627,10 +627,15 @@ def upload_image_route(caseId):
627
  def get_case_images(caseId):
628
 
629
  try:
 
 
 
630
  # Fetch images with only file_path and case_id
631
  images = list(db.db.images.find(
632
- {"case_id": caseId},
633
- {"file_path": 1, "case_id": 1, "_id": 0} # exclude _id
 
 
634
  ))
635
 
636
  if not images:
@@ -651,9 +656,6 @@ def get_case_images(caseId):
651
  print(f"❌ Error fetching images for case {caseId}: {e}")
652
  return jsonify({"error": str(e)}), 500
653
 
654
-
655
-
656
-
657
  @case_bp.route('/getfilee/<string:caseId>',methods=['GET'])
658
  def filee_route(caseId):
659
 
@@ -716,7 +718,10 @@ def get_status(caseId):
716
  @case_bp.route('/fetch_img_analysis/<string:caseId>',methods=['GET'])
717
  def fetch_img_analysis(caseId):
718
  try:
719
- img=db.db.images.find({'case_id':caseId})
 
 
 
720
  analysis_results = []
721
  for image in img:
722
  analysis_results.append({
@@ -732,4 +737,3 @@ def fetch_img_analysis(caseId):
732
  print(f"❌ Error getting image analysis: {e}")
733
  return jsonify({"images":img}), 404
734
 
735
-
 
627
  def get_case_images(caseId):
628
 
629
  try:
630
+
631
+ case_data = db.db.cases.find_one({"_id":ObjectId(caseId)})
632
+ print(case_data)
633
  # Fetch images with only file_path and case_id
634
  images = list(db.db.images.find(
635
+ {"case_id": caseId,"user_id":case_data['user_id']},
636
+
637
+ {"file_path": 1, "case_id": 1, "_id": 0,
638
+ } # exclude _id
639
  ))
640
 
641
  if not images:
 
656
  print(f"❌ Error fetching images for case {caseId}: {e}")
657
  return jsonify({"error": str(e)}), 500
658
 
 
 
 
659
  @case_bp.route('/getfilee/<string:caseId>',methods=['GET'])
660
  def filee_route(caseId):
661
 
 
718
  @case_bp.route('/fetch_img_analysis/<string:caseId>',methods=['GET'])
719
  def fetch_img_analysis(caseId):
720
  try:
721
+ case_data = db.db.cases.find_one({"_id":ObjectId(caseId)})
722
+ if isinstance(case_data['officer'], ObjectId):
723
+ officer_id = str(case_data['officer'])
724
+ img=db.db.images.find({'case_id':caseId,"user_id":officer_id})
725
  analysis_results = []
726
  for image in img:
727
  analysis_results.append({
 
737
  print(f"❌ Error getting image analysis: {e}")
738
  return jsonify({"images":img}), 404
739