add error state filtering

This commit is contained in:
Simon
2025-07-10 12:28:49 +07:00
parent ffd3bab948
commit 29be11cf75
4 changed files with 99 additions and 75 deletions

View File

@@ -48,6 +48,7 @@ class DownloadListQuerySerializer(
channel = serializers.CharField(required=False, help_text="channel ID")
page = serializers.IntegerField(required=False)
q = serializers.CharField(required=False, help_text="Search Query")
error = serializers.BooleanField(required=False, allow_null=True)
class DownloadListQueueDeleteQuerySerializer(serializers.Serializer):

View File

@@ -77,6 +77,12 @@ class DownloadApiListView(ApiBaseView):
if search_query:
must_list.append({"match_phrase_prefix": {"title": search_query}})
if validated_data.get("error") is not None:
operator = "must" if validated_data["error"] else "must_not"
must_list.append(
{"bool": {operator: [{"exists": {"field": "message"}}]}}
)
self.data["query"] = {"bool": {"must": must_list}}
self.get_document_list(request)