Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

chore: issue list date filters and properties #1820

Merged
merged 3 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apiserver/plane/api/serializers/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ class Meta:
"updated_at",
]

def validate(self, data):
if data.get("start_date", None) is not None and data.get("target_date", None) is not None and data.get("start_date", None) > data.get("target_date", None):
raise serializers.ValidationError("Start date cannot exceed target date")
return data

def create(self, validated_data):
blockers = validated_data.pop("blockers_list", None)
assignees = validated_data.pop("assignees_list", None)
Expand Down
1 change: 0 additions & 1 deletion apiserver/plane/api/views/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ def get_queryset(self):
def list(self, request, slug, project_id):
try:
filters = issue_filters(request.query_params, "GET")
print(filters)

# Custom ordering for priority and state
priority_order = ["urgent", "high", "medium", "low", None]
Expand Down
38 changes: 38 additions & 0 deletions apiserver/plane/db/migrations/0043_auto_20230809_1645.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 4.2.3 on 2023-08-09 11:15

from django.db import migrations


def update_user_issue_properties(apps, schema_editor):
IssuePropertyModel = apps.get_model("db", "IssueProperty")
updated_issue_properties = []
for obj in IssuePropertyModel.objects.all():
obj.properties["start_date"] = True
updated_issue_properties.append(obj)
IssuePropertyModel.objects.bulk_update(
updated_issue_properties, ["properties"], batch_size=100
)


def workspace_member_properties(apps, schema_editor):
WorkspaceMemberModel = apps.get_model("db", "WorkspaceMember")
updated_workspace_members = []
for obj in WorkspaceMemberModel.objects.all():
obj.view_props["properties"]["start_date"] = True
obj.default_props["properties"]["start_date"] = True
updated_workspace_members.append(obj)

WorkspaceMemberModel.objects.bulk_update(
updated_workspace_members, ["view_props", "default_props"], batch_size=100
)


class Migration(migrations.Migration):
dependencies = [
("db", "0042_alter_analyticview_created_by_and_more"),
]

operations = [
migrations.RunPython(update_user_issue_properties),
migrations.RunPython(workspace_member_properties),
]
1 change: 1 addition & 0 deletions apiserver/plane/db/models/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def get_default_props():
"estimate": True,
"created_on": True,
"updated_on": True,
"start_date": True,
},
"showEmptyGroups": True,
}
Expand Down
10 changes: 9 additions & 1 deletion apiserver/plane/utils/issue_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,16 @@ def filter_subscribed_issues(params, filter, method):
return filter


def filter_start_target_date_issues(params, filter, method):
start_target_date = params.get("start_target_date", "false")
if start_target_date == "true":
filter["target_date__isnull"] = False
filter["start_date__isnull"] = False
return filter


def issue_filters(query_params, method):
filter = dict()
print(query_params)

ISSUE_FILTER = {
"state": filter_state,
Expand All @@ -318,6 +325,7 @@ def issue_filters(query_params, method):
"inbox_status": filter_inbox_status,
"sub_issue": filter_sub_issue_toggle,
"subscriber": filter_subscribed_issues,
"start_target_date": filter_start_target_date_issues,
}

for key, value in ISSUE_FILTER.items():
Expand Down