Spaces:
Running
Running
Update backend/src/routes/report.py
Browse files- backend/src/routes/report.py +13 -4
backend/src/routes/report.py
CHANGED
@@ -17,17 +17,22 @@ from model.image import I
|
|
17 |
from langchain_core.prompts import PromptTemplate
|
18 |
from config.config import get_mongo_connection
|
19 |
from bson import ObjectId
|
|
|
20 |
|
21 |
report_bp = Blueprint('report', __name__)
|
22 |
@report_bp.route("/display", methods=["GET"])
|
23 |
def display():
|
24 |
case_id = request.args.get("case_id")
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
|
27 |
print("case_id:", case_id)
|
28 |
print("records:", l)
|
29 |
|
30 |
-
# Format the results
|
31 |
analysis_results = []
|
32 |
for i in l:
|
33 |
result = {
|
@@ -47,13 +52,17 @@ def generate_report():
|
|
47 |
|
48 |
case_id = request.args.get("case_id")
|
49 |
|
|
|
50 |
# Fetch images
|
51 |
-
|
|
|
|
|
|
|
|
|
52 |
if not image_list:
|
53 |
return jsonify({"error": "No images found for this case."}), 404
|
54 |
|
55 |
# Connect to MongoDB
|
56 |
-
db = get_mongo_connection()
|
57 |
if db is None:
|
58 |
return jsonify({"error": "Failed to connect to database"}), 500
|
59 |
|
|
|
17 |
from langchain_core.prompts import PromptTemplate
|
18 |
from config.config import get_mongo_connection
|
19 |
from bson import ObjectId
|
20 |
+
db = get_mongo_connection()
|
21 |
|
22 |
report_bp = Blueprint('report', __name__)
|
23 |
@report_bp.route("/display", methods=["GET"])
|
24 |
def display():
|
25 |
case_id = request.args.get("case_id")
|
26 |
+
case_data = db.db.cases.find_one({"_id":ObjectId(case_id)})
|
27 |
+
if isinstance(case_data['officer'], ObjectId):
|
28 |
+
officer_id = str(case_data['officer'])
|
29 |
+
l=db.db.images.find({'case_id':case_id,"user_id":officer_id})
|
30 |
+
# l = I.get_by_case_id(case_id) # Your DB fetch function
|
31 |
|
32 |
print("case_id:", case_id)
|
33 |
print("records:", l)
|
34 |
|
35 |
+
# Format the results
|
36 |
analysis_results = []
|
37 |
for i in l:
|
38 |
result = {
|
|
|
52 |
|
53 |
case_id = request.args.get("case_id")
|
54 |
|
55 |
+
db = get_mongo_connection()
|
56 |
# Fetch images
|
57 |
+
case_data = db.db.cases.find_one({"_id":ObjectId(case_id)})
|
58 |
+
if isinstance(case_data['officer'], ObjectId):
|
59 |
+
officer_id = str(case_data['officer'])
|
60 |
+
image_list=db.db.images.find({'case_id':case_id,"user_id":officer_id})
|
61 |
+
# image_list = I.get_by_case_id(case_id)
|
62 |
if not image_list:
|
63 |
return jsonify({"error": "No images found for this case."}), 404
|
64 |
|
65 |
# Connect to MongoDB
|
|
|
66 |
if db is None:
|
67 |
return jsonify({"error": "Failed to connect to database"}), 500
|
68 |
|