UPDATE: add field to request detail api
This commit is contained in:
parent
c82fac1572
commit
fda47870dc
@ -572,27 +572,32 @@ class RequestViewSet(viewsets.ViewSet):
|
|||||||
subscription_request = subscription_request.first()
|
subscription_request = subscription_request.first()
|
||||||
|
|
||||||
data = []
|
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({
|
data.append({
|
||||||
'Document Type': subscription_request.doc_type,
|
'Document Type': subscription_request.doc_type,
|
||||||
'RequestID': subscription_request.request_id,
|
'RequestID': subscription_request.request_id,
|
||||||
@ -600,19 +605,19 @@ class RequestViewSet(viewsets.ViewSet):
|
|||||||
'Process Type': subscription_request.process_type,
|
'Process Type': subscription_request.process_type,
|
||||||
'Provider Code': subscription_request.provider_code,
|
'Provider Code': subscription_request.provider_code,
|
||||||
'Status': subscription_request.status,
|
'Status': subscription_request.status,
|
||||||
'IMEIs': imeis,
|
'Files': files,
|
||||||
'Purchase Date': purchase_date,
|
'Reviewed Result': subscription_request.reviewed_result,
|
||||||
'Retailer': retailer,
|
'Feedback Result': subscription_request.feedback_result,
|
||||||
'Reviewed result': subscription_request.reviewed_result,
|
'Predicted Result': subscription_request.predict_result,
|
||||||
'Feedback result': subscription_request.feedback_result,
|
|
||||||
'Is Test Request': subscription_request.is_test_request,
|
'Is Test Request': subscription_request.is_test_request,
|
||||||
'Client Request Time (ms)': subscription_request.client_request_time,
|
'Client Request Time (ms)': subscription_request.client_request_time,
|
||||||
'Server Processing Time (ms)': subscription_request.preprocessing_time + subscription_request.ai_inference_time,
|
'Server Processing Time (ms)': subscription_request.preprocessing_time + subscription_request.ai_inference_time,
|
||||||
'Is Reviewed': subscription_request.is_reviewed,
|
'Is Reviewed': subscription_request.is_reviewed,
|
||||||
|
'Subscription': subscription_request.subscription,
|
||||||
# 'Is Bad Quality': subscription_request.is_bad_image_quality,
|
'Feedback Accuracy': subscription_request.feedback_accuracy,
|
||||||
'created_at': subscription_request.created_at.isoformat(),
|
'Reviewed Accuracy': subscription_request.reviewed_accuracy,
|
||||||
'updated_at': subscription_request.updated_at.isoformat()
|
'Created At': subscription_request.created_at.isoformat(),
|
||||||
|
'Updated At': subscription_request.updated_at.isoformat()
|
||||||
})
|
})
|
||||||
|
|
||||||
response = {
|
response = {
|
||||||
|
Loading…
Reference in New Issue
Block a user