forked from github/plane
fix: issue search for blocking and blocked_by condition (#1182)
* fix: issue search for blocking and blocked_by condition * fix: issue search endpoint blockers * fix: rectify the filter parameters
This commit is contained in:
parent
50060a0bf9
commit
58d1d8f132
@ -210,13 +210,15 @@ class IssueSearchEndpoint(BaseAPIView):
|
||||
blocker_blocked_by = request.query_params.get("blocker_blocked_by", False)
|
||||
issue_id = request.query_params.get("issue_id", False)
|
||||
|
||||
issues = search_issues(query)
|
||||
issues = issues.filter(
|
||||
issues = Issue.objects.filter(
|
||||
workspace__slug=slug,
|
||||
project_id=project_id,
|
||||
project__project_projectmember__member=self.request.user,
|
||||
)
|
||||
|
||||
if query:
|
||||
issues = search_issues(query, issues)
|
||||
|
||||
if parent == "true" and issue_id:
|
||||
issue = Issue.objects.get(pk=issue_id)
|
||||
issues = issues.filter(
|
||||
@ -227,7 +229,12 @@ class IssueSearchEndpoint(BaseAPIView):
|
||||
)
|
||||
)
|
||||
if blocker_blocked_by == "true" and issue_id:
|
||||
issues = issues.filter(blocker_issues=issue_id, blocked_issues=issue_id)
|
||||
issue = Issue.objects.get(pk=issue_id)
|
||||
issues = issues.filter(
|
||||
~Q(pk=issue_id),
|
||||
~Q(blocked_issues__block=issue),
|
||||
~Q(blocker_issues__blocked_by=issue),
|
||||
)
|
||||
|
||||
return Response(
|
||||
issues.values(
|
||||
|
@ -8,7 +8,7 @@ from django.db.models import Q
|
||||
from plane.db.models import Issue
|
||||
|
||||
|
||||
def search_issues(query):
|
||||
def search_issues(query, queryset):
|
||||
fields = ["name", "sequence_id"]
|
||||
q = Q()
|
||||
for field in fields:
|
||||
@ -18,6 +18,6 @@ def search_issues(query):
|
||||
q |= Q(**{"sequence_id": sequence_id})
|
||||
else:
|
||||
q |= Q(**{f"{field}__icontains": query})
|
||||
return Issue.objects.filter(
|
||||
return queryset.filter(
|
||||
q,
|
||||
).distinct()
|
||||
|
Loading…
Reference in New Issue
Block a user