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

@@ -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)