feat: add issue filters for cycles and modules (#475)

This commit is contained in:
pablohashescobar 2023-03-22 01:36:06 +05:30 committed by GitHub
parent 4dc76eac19
commit 846e73e3b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -32,6 +32,7 @@ from plane.db.models import (
)
from plane.bgtasks.issue_activites_task import issue_activity
from plane.utils.grouper import group_results
from plane.utils.issue_filters import issue_filters
class CycleViewSet(BaseViewSet):
@ -143,7 +144,7 @@ class CycleIssueViewSet(BaseViewSet):
try:
order_by = request.GET.get("order_by", "created_at")
group_by = request.GET.get("group_by", False)
filters = issue_filters(request.query_params, "GET")
issues = (
Issue.objects.filter(issue_cycle__cycle_id=cycle_id)
.annotate(
@ -162,6 +163,7 @@ class CycleIssueViewSet(BaseViewSet):
.prefetch_related("assignees")
.prefetch_related("labels")
.order_by(order_by)
.filter(**filters)
)
issues_data = IssueStateSerializer(issues, many=True).data

View File

@ -32,6 +32,7 @@ from plane.db.models import (
)
from plane.bgtasks.issue_activites_task import issue_activity
from plane.utils.grouper import group_results
from plane.utils.issue_filters import issue_filters
class ModuleViewSet(BaseViewSet):
@ -156,7 +157,7 @@ class ModuleIssueViewSet(BaseViewSet):
try:
order_by = request.GET.get("order_by", "created_at")
group_by = request.GET.get("group_by", False)
filters = issue_filters(request.query_params, "GET")
issues = (
Issue.objects.filter(issue_module__module_id=module_id)
.annotate(
@ -175,6 +176,7 @@ class ModuleIssueViewSet(BaseViewSet):
.prefetch_related("assignees")
.prefetch_related("labels")
.order_by(order_by)
.filter(**filters)
)
issues_data = IssueStateSerializer(issues, many=True).data

View File

@ -24,6 +24,7 @@ from plane.db.models import (
ModuleIssue,
IssueViewFavorite,
)
from plane.utils.issue_filters import issue_filters
class IssueViewViewSet(BaseViewSet):
@ -66,10 +67,13 @@ class ViewIssuesEndpoint(BaseAPIView):
view = IssueView.objects.get(pk=view_id)
queries = view.query
filters = issue_filters(request.query_params, "GET")
issues = (
Issue.objects.filter(
**queries, project_id=project_id, workspace__slug=slug
)
.filter(**filters)
.select_related("project")
.select_related("workspace")
.select_related("state")