forked from github/plane
feat: add issue filters for cycles and modules (#475)
This commit is contained in:
parent
4dc76eac19
commit
846e73e3b8
@ -32,6 +32,7 @@ from plane.db.models import (
|
|||||||
)
|
)
|
||||||
from plane.bgtasks.issue_activites_task import issue_activity
|
from plane.bgtasks.issue_activites_task import issue_activity
|
||||||
from plane.utils.grouper import group_results
|
from plane.utils.grouper import group_results
|
||||||
|
from plane.utils.issue_filters import issue_filters
|
||||||
|
|
||||||
|
|
||||||
class CycleViewSet(BaseViewSet):
|
class CycleViewSet(BaseViewSet):
|
||||||
@ -143,7 +144,7 @@ class CycleIssueViewSet(BaseViewSet):
|
|||||||
try:
|
try:
|
||||||
order_by = request.GET.get("order_by", "created_at")
|
order_by = request.GET.get("order_by", "created_at")
|
||||||
group_by = request.GET.get("group_by", False)
|
group_by = request.GET.get("group_by", False)
|
||||||
|
filters = issue_filters(request.query_params, "GET")
|
||||||
issues = (
|
issues = (
|
||||||
Issue.objects.filter(issue_cycle__cycle_id=cycle_id)
|
Issue.objects.filter(issue_cycle__cycle_id=cycle_id)
|
||||||
.annotate(
|
.annotate(
|
||||||
@ -162,6 +163,7 @@ class CycleIssueViewSet(BaseViewSet):
|
|||||||
.prefetch_related("assignees")
|
.prefetch_related("assignees")
|
||||||
.prefetch_related("labels")
|
.prefetch_related("labels")
|
||||||
.order_by(order_by)
|
.order_by(order_by)
|
||||||
|
.filter(**filters)
|
||||||
)
|
)
|
||||||
|
|
||||||
issues_data = IssueStateSerializer(issues, many=True).data
|
issues_data = IssueStateSerializer(issues, many=True).data
|
||||||
|
@ -32,6 +32,7 @@ from plane.db.models import (
|
|||||||
)
|
)
|
||||||
from plane.bgtasks.issue_activites_task import issue_activity
|
from plane.bgtasks.issue_activites_task import issue_activity
|
||||||
from plane.utils.grouper import group_results
|
from plane.utils.grouper import group_results
|
||||||
|
from plane.utils.issue_filters import issue_filters
|
||||||
|
|
||||||
|
|
||||||
class ModuleViewSet(BaseViewSet):
|
class ModuleViewSet(BaseViewSet):
|
||||||
@ -156,7 +157,7 @@ class ModuleIssueViewSet(BaseViewSet):
|
|||||||
try:
|
try:
|
||||||
order_by = request.GET.get("order_by", "created_at")
|
order_by = request.GET.get("order_by", "created_at")
|
||||||
group_by = request.GET.get("group_by", False)
|
group_by = request.GET.get("group_by", False)
|
||||||
|
filters = issue_filters(request.query_params, "GET")
|
||||||
issues = (
|
issues = (
|
||||||
Issue.objects.filter(issue_module__module_id=module_id)
|
Issue.objects.filter(issue_module__module_id=module_id)
|
||||||
.annotate(
|
.annotate(
|
||||||
@ -175,6 +176,7 @@ class ModuleIssueViewSet(BaseViewSet):
|
|||||||
.prefetch_related("assignees")
|
.prefetch_related("assignees")
|
||||||
.prefetch_related("labels")
|
.prefetch_related("labels")
|
||||||
.order_by(order_by)
|
.order_by(order_by)
|
||||||
|
.filter(**filters)
|
||||||
)
|
)
|
||||||
|
|
||||||
issues_data = IssueStateSerializer(issues, many=True).data
|
issues_data = IssueStateSerializer(issues, many=True).data
|
||||||
|
@ -24,6 +24,7 @@ from plane.db.models import (
|
|||||||
ModuleIssue,
|
ModuleIssue,
|
||||||
IssueViewFavorite,
|
IssueViewFavorite,
|
||||||
)
|
)
|
||||||
|
from plane.utils.issue_filters import issue_filters
|
||||||
|
|
||||||
|
|
||||||
class IssueViewViewSet(BaseViewSet):
|
class IssueViewViewSet(BaseViewSet):
|
||||||
@ -66,10 +67,13 @@ class ViewIssuesEndpoint(BaseAPIView):
|
|||||||
view = IssueView.objects.get(pk=view_id)
|
view = IssueView.objects.get(pk=view_id)
|
||||||
queries = view.query
|
queries = view.query
|
||||||
|
|
||||||
|
filters = issue_filters(request.query_params, "GET")
|
||||||
|
|
||||||
issues = (
|
issues = (
|
||||||
Issue.objects.filter(
|
Issue.objects.filter(
|
||||||
**queries, project_id=project_id, workspace__slug=slug
|
**queries, project_id=project_id, workspace__slug=slug
|
||||||
)
|
)
|
||||||
|
.filter(**filters)
|
||||||
.select_related("project")
|
.select_related("project")
|
||||||
.select_related("workspace")
|
.select_related("workspace")
|
||||||
.select_related("state")
|
.select_related("state")
|
||||||
|
Loading…
Reference in New Issue
Block a user