Update API
This commit is contained in:
parent
d0f15040ef
commit
c6d11755c1
@ -731,7 +731,7 @@ class AccuracyViewSet(viewsets.ViewSet):
|
|||||||
|
|
||||||
@extend_schema(
|
@extend_schema(
|
||||||
request={
|
request={
|
||||||
'multipart/form-data': {
|
'application/json': {
|
||||||
'type': 'object',
|
'type': 'object',
|
||||||
'properties': {
|
'properties': {
|
||||||
'request_file_results': {
|
'request_file_results': {
|
||||||
@ -739,7 +739,7 @@ class AccuracyViewSet(viewsets.ViewSet):
|
|||||||
'items': {
|
'items': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
# 'format': 'binary',
|
# 'format': 'binary',
|
||||||
'default': '''{"request_file_id": "Sample request_id", "imei_number": "sample_imei1", "retailername": "Sample Retailer", "purchase_date": "01/01/1970", "sold_to_party": "Sample party", "invoice_no": "Sample Invoice no"}''',
|
'default': {"request_file_id": "Sample request_id", "imei_number": "sample_imei1", "retailername": "Sample Retailer", "purchase_date": "01/01/1970", "sold_to_party": "Sample party", "invoice_no": "Sample Invoice no"},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -813,7 +813,9 @@ class AccuracyViewSet(viewsets.ViewSet):
|
|||||||
'Feedback Accuracy': subscription_request_file.feedback_accuracy,
|
'Feedback Accuracy': subscription_request_file.feedback_accuracy,
|
||||||
'Reviewed Accuracy': subscription_request_file.reviewed_accuracy,
|
'Reviewed Accuracy': subscription_request_file.reviewed_accuracy,
|
||||||
'Created At': subscription_request_file.created_at.isoformat(),
|
'Created At': subscription_request_file.created_at.isoformat(),
|
||||||
'Updated At': subscription_request_file.updated_at.isoformat()
|
'Updated At': subscription_request_file.updated_at.isoformat(),
|
||||||
|
'Is Reviewed': subscription_request_file.is_reviewed,
|
||||||
|
'Is Required': subscription_request_file.is_required,
|
||||||
})
|
})
|
||||||
|
|
||||||
reviewed_result = subscription_request.reviewed_result
|
reviewed_result = subscription_request.reviewed_result
|
||||||
@ -847,6 +849,7 @@ class AccuracyViewSet(viewsets.ViewSet):
|
|||||||
'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,
|
||||||
|
'Is Required': subscription_request.is_required,
|
||||||
'Feedback Accuracy': subscription_request.feedback_accuracy,
|
'Feedback Accuracy': subscription_request.feedback_accuracy,
|
||||||
'Reviewed Accuracy': subscription_request.reviewed_accuracy,
|
'Reviewed Accuracy': subscription_request.reviewed_accuracy,
|
||||||
'Created At': subscription_request.created_at.isoformat(),
|
'Created At': subscription_request.created_at.isoformat(),
|
||||||
@ -911,22 +914,29 @@ class AccuracyViewSet(viewsets.ViewSet):
|
|||||||
rf.is_reviewed = True
|
rf.is_reviewed = True
|
||||||
rf.save()
|
rf.save()
|
||||||
|
|
||||||
|
subscription_request.is_reviewed = True
|
||||||
|
subscription_request.save()
|
||||||
|
|
||||||
return JsonResponse({'message': 'success.'}, status=200)
|
return JsonResponse({'message': 'success.'}, status=200)
|
||||||
else:
|
else:
|
||||||
return JsonResponse({'error': 'Invalid request method.'}, status=405)
|
return JsonResponse({'error': 'Invalid request method.'}, status=405)
|
||||||
|
|
||||||
@extend_schema(
|
@extend_schema(
|
||||||
request={
|
request={
|
||||||
'multipart/form-data': {
|
'application/json': {
|
||||||
'type': 'object',
|
'type': 'object',
|
||||||
'properties': {
|
'properties': {
|
||||||
|
'request_file_result': {
|
||||||
|
'type': 'string',
|
||||||
|
'default': {"request_file_id": "Sample request_id", "imei_number": "sample_imei1", "retailername": "Sample Retailer", "purchase_date": "01/01/1970", "sold_to_party": "Sample party", "invoice_no": "Sample Invoice no"},
|
||||||
|
},
|
||||||
'reason': {
|
'reason': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'default': '''"Sample reason"''',
|
'default': "Sample reason",
|
||||||
},
|
},
|
||||||
'solution': {
|
'solution': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'default': '''"Sample Solution"''',
|
'default': "Sample Solution",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -959,12 +969,34 @@ class AccuracyViewSet(viewsets.ViewSet):
|
|||||||
|
|
||||||
reason = data["reason"]
|
reason = data["reason"]
|
||||||
solution = data["solution"]
|
solution = data["solution"]
|
||||||
|
file_result = data["request_file_result"]
|
||||||
|
|
||||||
is_available = False
|
is_available = False
|
||||||
for subscription_request_file in subscription_request_files:
|
for subscription_request_file in subscription_request_files:
|
||||||
if subscription_request_file.file_name.split(".")[0] == request_image_id:
|
if subscription_request_file.file_name.split(".")[0] == request_image_id:
|
||||||
|
sample_result = {
|
||||||
|
"request_id": request_id,
|
||||||
|
"retailername": None,
|
||||||
|
"sold_to_party": None,
|
||||||
|
"invoice_no": None,
|
||||||
|
"purchase_date": None,
|
||||||
|
"imei_number": []
|
||||||
|
}
|
||||||
|
for k, v in file_result.items():
|
||||||
|
if k in sample_result.keys():
|
||||||
|
if not isinstance(sample_result[k], list):
|
||||||
|
sample_result[k] = v
|
||||||
|
else:
|
||||||
|
sample_result[k].append(v)
|
||||||
|
|
||||||
|
if subscription_request_file.reviewed_result is not None:
|
||||||
|
subscription_request_file.reviewed_result.update(sample_result)
|
||||||
|
else:
|
||||||
|
subscription_request_file.reviewed_result = sample_result
|
||||||
|
|
||||||
subscription_request_file.reason = reason
|
subscription_request_file.reason = reason
|
||||||
subscription_request_file.counter_measures = solution
|
subscription_request_file.counter_measures = solution
|
||||||
|
subscription_request_file.is_reviewed = True
|
||||||
subscription_request_file.save()
|
subscription_request_file.save()
|
||||||
is_available = True
|
is_available = True
|
||||||
if not is_available:
|
if not is_available:
|
||||||
|
Loading…
Reference in New Issue
Block a user