Add: filter to search
This commit is contained in:
parent
669bef9528
commit
a282e9c505
@ -112,6 +112,34 @@ class AccuracyViewSet(viewsets.ViewSet):
|
||||
type=OpenApiTypes.FLOAT,
|
||||
required=False
|
||||
),
|
||||
OpenApiParameter(
|
||||
name='predict_result',
|
||||
location=OpenApiParameter.QUERY,
|
||||
description='Filter by predict result',
|
||||
type=OpenApiTypes.STR,
|
||||
required=False
|
||||
),
|
||||
OpenApiParameter(
|
||||
name='feedback_result',
|
||||
location=OpenApiParameter.QUERY,
|
||||
description='Filter by feedback result',
|
||||
type=OpenApiTypes.STR,
|
||||
required=False
|
||||
),
|
||||
OpenApiParameter(
|
||||
name='reviewed_result',
|
||||
location=OpenApiParameter.QUERY,
|
||||
description='Filter by reviewed result',
|
||||
type=OpenApiTypes.STR,
|
||||
required=False
|
||||
),
|
||||
OpenApiParameter(
|
||||
name='doc_type',
|
||||
location=OpenApiParameter.QUERY,
|
||||
description='Filter by document type',
|
||||
type=OpenApiTypes.STR,
|
||||
required=False
|
||||
),
|
||||
],
|
||||
responses=None, tags=['Accuracy']
|
||||
)
|
||||
@ -129,7 +157,10 @@ class AccuracyViewSet(viewsets.ViewSet):
|
||||
include_test = request.GET.get('includes_test', False)
|
||||
subsidiary = request.GET.get("subsidiary", "all")
|
||||
max_accuracy = float(request.GET.get("max_accuracy", 100))
|
||||
# subsidiary = map_subsidiary_long_to_short(subsidiary)
|
||||
predict_result = request.GET.get('predict_result', None)
|
||||
feedback_result = request.GET.get('feedback_result', None)
|
||||
reviewed_result = request.GET.get('reviewed_result', None)
|
||||
doc_type = request.GET.get('doc_type', None)
|
||||
|
||||
base_query = Q(status=200)
|
||||
if start_date_str or end_date_str:
|
||||
@ -193,6 +224,15 @@ class AccuracyViewSet(viewsets.ViewSet):
|
||||
base_query &= Q(
|
||||
redemption_id__startswith=map_subsidiary_long_to_short(subsidiary))
|
||||
|
||||
if predict_result:
|
||||
base_query &= Q(predict_result__icontains=predict_result)
|
||||
if feedback_result:
|
||||
base_query &= Q(feedback_result__icontains=feedback_result)
|
||||
if reviewed_result:
|
||||
base_query &= Q(reviewed_result__icontains=reviewed_result)
|
||||
if doc_type:
|
||||
base_query &= Q(doc_type__icontains=doc_type)
|
||||
|
||||
if isinstance(max_accuracy, float):
|
||||
base_query &= Q(raw_accuracy__lt=(
|
||||
max_accuracy/100)) | Q(raw_accuracy__isnull=True)
|
||||
|
Loading…
Reference in New Issue
Block a user