diff --git a/cope2n-api/fwd_api/api/accuracy_view.py b/cope2n-api/fwd_api/api/accuracy_view.py index afd0628..f5cfc11 100644 --- a/cope2n-api/fwd_api/api/accuracy_view.py +++ b/cope2n-api/fwd_api/api/accuracy_view.py @@ -572,27 +572,32 @@ class RequestViewSet(viewsets.ViewSet): subscription_request = subscription_request.first() data = [] + files = [] + + file_query = Q(request=request_id) + + subscription_request_files = SubscriptionRequestFile.objects.filter(file_query) + + for subscription_request_file in subscription_request_files: + files.append({ + 'File Name': subscription_request_file.file_name, + 'File Path': subscription_request_file.file_path, + 'File Category': subscription_request_file.file_category, + 'Origin_Name': subscription_request_file.origin_name, + 'Is Bad Image Quality': subscription_request_file.is_bad_image_quality, + 'Doc Type': subscription_request_file.doc_type, + 'Processing Time (ms)': subscription_request_file.processing_time, + 'Reason': subscription_request_file.reason, + 'Counter Measures': subscription_request_file.counter_measures, + 'Predicted Result': subscription_request_file.predict_result, + 'Feedback Result': subscription_request_file.feedback_result, + 'Reviewed Result': subscription_request_file.reviewed_result, + 'Feedback Accuracy': subscription_request_file.feedback_accuracy, + 'Reviewed Accuracy': subscription_request_file.reviewed_accuracy, + 'Created At': subscription_request_file.created_at.isoformat(), + 'Updated At': subscription_request_file.updated_at.isoformat() + }) - imeis = [] - purchase_date = [] - retailer = "" - try: - if subscription_request.reviewed_result is not None: - imeis = subscription_request.reviewed_result.get("imei_number", []) - purchase_date = subscription_request.reviewed_result.get("purchase_date", []) - retailer = subscription_request.reviewed_result.get("retailername", "") - elif subscription_request.feedback_result is not None : - imeis = subscription_request.feedback_result.get("imei_number", []) - purchase_date = subscription_request.feedback_result.get("purchase_date", []) - retailer = subscription_request.feedback_result.get("retailername", "") - elif subscription_request.predict_result is not None: - if subscription_request.predict_result.get("status", 404) == 200: - imeis = subscription_request.predict_result.get("content", {}).get("document", [])[0].get("content", [])[3].get("value", []) - purchase_date = subscription_request.predict_result.get("content", {}).get("document", [])[0].get("content", [])[2].get("value", []) - retailer = subscription_request.predict_result.get("content", {}).get("document", [])[0].get("content", [])[0].get("value", []) - except Exception as e: - print(f"[ERROR]: {e}") - print(f"[ERROR]: {subscription_request}") data.append({ 'Document Type': subscription_request.doc_type, 'RequestID': subscription_request.request_id, @@ -600,19 +605,19 @@ class RequestViewSet(viewsets.ViewSet): 'Process Type': subscription_request.process_type, 'Provider Code': subscription_request.provider_code, 'Status': subscription_request.status, - 'IMEIs': imeis, - 'Purchase Date': purchase_date, - 'Retailer': retailer, - 'Reviewed result': subscription_request.reviewed_result, - 'Feedback result': subscription_request.feedback_result, + 'Files': files, + 'Reviewed Result': subscription_request.reviewed_result, + 'Feedback Result': subscription_request.feedback_result, + 'Predicted Result': subscription_request.predict_result, 'Is Test Request': subscription_request.is_test_request, 'Client Request Time (ms)': subscription_request.client_request_time, 'Server Processing Time (ms)': subscription_request.preprocessing_time + subscription_request.ai_inference_time, 'Is Reviewed': subscription_request.is_reviewed, - - # 'Is Bad Quality': subscription_request.is_bad_image_quality, - 'created_at': subscription_request.created_at.isoformat(), - 'updated_at': subscription_request.updated_at.isoformat() + 'Subscription': subscription_request.subscription, + 'Feedback Accuracy': subscription_request.feedback_accuracy, + 'Reviewed Accuracy': subscription_request.reviewed_accuracy, + 'Created At': subscription_request.created_at.isoformat(), + 'Updated At': subscription_request.updated_at.isoformat() }) response = {