Add: bad_reason filter
This commit is contained in:
parent
55c81a2dcf
commit
1867259d5e
@ -142,6 +142,13 @@ class AccuracyViewSet(viewsets.ViewSet):
|
||||
enum=list(settings.DOC_TYPES),
|
||||
required=False
|
||||
),
|
||||
OpenApiParameter(
|
||||
name='bad_reason',
|
||||
location=OpenApiParameter.QUERY,
|
||||
description='Filter by bad reason',
|
||||
type=OpenApiTypes.STR,
|
||||
required=False
|
||||
),
|
||||
],
|
||||
responses=None, tags=['Accuracy']
|
||||
)
|
||||
@ -163,6 +170,7 @@ class AccuracyViewSet(viewsets.ViewSet):
|
||||
feedback_result = request.GET.get('feedback_result', None)
|
||||
reviewed_result = request.GET.get('reviewed_result', None)
|
||||
doc_type = request.GET.get('doc_type', None)
|
||||
bad_reason = request.GET.get('bad_reason', None)
|
||||
|
||||
base_query = Q(status=200)
|
||||
if start_date_str or end_date_str:
|
||||
@ -242,6 +250,12 @@ class AccuracyViewSet(viewsets.ViewSet):
|
||||
base_query &= Q(raw_accuracy__lt=(
|
||||
max_accuracy/100)) | Q(raw_accuracy__isnull=True)
|
||||
|
||||
if bad_reason:
|
||||
bad_reason_subquery = SubscriptionRequestFile.objects.filter(
|
||||
reason__icontains=bad_reason
|
||||
).values_list('request_id', flat=True)
|
||||
base_query &= Q(id__in=bad_reason_subquery)
|
||||
|
||||
subscription_requests = SubscriptionRequest.objects.filter(
|
||||
base_query).order_by('created_at')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user