chore: issue list date filters and properties (#1820)

* dev: start date and target date validation and filter for null dated issues

* dev: remove print logs

* dev: issue property dates
This commit is contained in:
Nikhil 2023-08-11 12:45:51 +05:30 committed by GitHub
parent 11abd3cadf
commit 0a1483c482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 2 deletions

View File

@ -111,6 +111,11 @@ class IssueCreateSerializer(BaseSerializer):
"updated_at", "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): def create(self, validated_data):
blockers = validated_data.pop("blockers_list", None) blockers = validated_data.pop("blockers_list", None)
assignees = validated_data.pop("assignees_list", None) assignees = validated_data.pop("assignees_list", None)

View File

@ -169,7 +169,6 @@ class IssueViewSet(BaseViewSet):
def list(self, request, slug, project_id): def list(self, request, slug, project_id):
try: try:
filters = issue_filters(request.query_params, "GET") filters = issue_filters(request.query_params, "GET")
print(filters)
# Custom ordering for priority and state # Custom ordering for priority and state
priority_order = ["urgent", "high", "medium", "low", None] priority_order = ["urgent", "high", "medium", "low", None]

View File

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

View File

@ -33,6 +33,7 @@ def get_default_props():
"estimate": True, "estimate": True,
"created_on": True, "created_on": True,
"updated_on": True, "updated_on": True,
"start_date": True,
}, },
"showEmptyGroups": True, "showEmptyGroups": True,
} }

View File

@ -292,9 +292,16 @@ def filter_subscribed_issues(params, filter, method):
return filter 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): def issue_filters(query_params, method):
filter = dict() filter = dict()
print(query_params)
ISSUE_FILTER = { ISSUE_FILTER = {
"state": filter_state, "state": filter_state,
@ -318,6 +325,7 @@ def issue_filters(query_params, method):
"inbox_status": filter_inbox_status, "inbox_status": filter_inbox_status,
"sub_issue": filter_sub_issue_toggle, "sub_issue": filter_sub_issue_toggle,
"subscriber": filter_subscribed_issues, "subscriber": filter_subscribed_issues,
"start_target_date": filter_start_target_date_issues,
} }
for key, value in ISSUE_FILTER.items(): for key, value in ISSUE_FILTER.items():