fix: changed priority from None to none (#2229)

This commit is contained in:
Bavisetti Narayan 2023-09-22 14:44:53 +05:30 committed by GitHub
parent 0c7b7c4e94
commit 0005ff5f99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 41 deletions

View File

@ -384,7 +384,7 @@ class BulkImportIssuesEndpoint(BaseAPIView):
sort_order=largest_sort_order, sort_order=largest_sort_order,
start_date=issue_data.get("start_date", None), start_date=issue_data.get("start_date", None),
target_date=issue_data.get("target_date", None), target_date=issue_data.get("target_date", None),
priority=issue_data.get("priority", None), priority=issue_data.get("priority", "none"),
created_by=request.user, created_by=request.user,
) )
) )

View File

@ -173,12 +173,12 @@ class InboxIssueViewSet(BaseViewSet):
) )
# Check for valid priority # Check for valid priority
if not request.data.get("issue", {}).get("priority", None) in [ if not request.data.get("issue", {}).get("priority", "none") in [
"low", "low",
"medium", "medium",
"high", "high",
"urgent", "urgent",
None, "none",
]: ]:
return Response( return Response(
{"error": "Invalid priority"}, status=status.HTTP_400_BAD_REQUEST {"error": "Invalid priority"}, status=status.HTTP_400_BAD_REQUEST
@ -480,12 +480,12 @@ class InboxIssuePublicViewSet(BaseViewSet):
) )
# Check for valid priority # Check for valid priority
if not request.data.get("issue", {}).get("priority", None) in [ if not request.data.get("issue", {}).get("priority", "none") in [
"low", "low",
"medium", "medium",
"high", "high",
"urgent", "urgent",
None, "none",
]: ]:
return Response( return Response(
{"error": "Invalid priority"}, status=status.HTTP_400_BAD_REQUEST {"error": "Invalid priority"}, status=status.HTTP_400_BAD_REQUEST

View File

@ -121,36 +121,20 @@ def track_priority(
epoch epoch
): ):
if current_instance.get("priority") != requested_data.get("priority"): if current_instance.get("priority") != requested_data.get("priority"):
if requested_data.get("priority") == None: issue_activities.append(
issue_activities.append( IssueActivity(
IssueActivity( issue_id=issue_id,
issue_id=issue_id, actor=actor,
actor=actor, verb="updated",
verb="updated", old_value=current_instance.get("priority"),
old_value=current_instance.get("priority"), new_value=requested_data.get("priority"),
new_value=None, field="priority",
field="priority", project=project,
project=project, workspace=project.workspace,
workspace=project.workspace, comment=f"updated the priority to {requested_data.get('priority')}",
comment=f"updated the priority to None", epoch=epoch,
epoch=epoch,
)
)
else:
issue_activities.append(
IssueActivity(
issue_id=issue_id,
actor=actor,
verb="updated",
old_value=current_instance.get("priority"),
new_value=requested_data.get("priority"),
field="priority",
project=project,
workspace=project.workspace,
comment=f"updated the priority to {requested_data.get('priority')}",
epoch=epoch,
)
) )
)
# Track chnages in state of the issue # Track chnages in state of the issue

View File

@ -0,0 +1,27 @@
# Generated by Django 4.2.3 on 2023-09-21 07:58
from django.db import migrations
def update_priority_history(apps, schema_editor):
IssueActivity = apps.get_model("db", "IssueActivity")
updated_issue_activity = []
for obj in IssueActivity.objects.all():
if obj.field == "priority":
obj.new_value = obj.new_value or "none"
obj.old_value = obj.old_value or "none"
updated_issue_activity.append(obj)
IssueActivity.objects.bulk_update(
updated_issue_activity, ["new_value", "old_value"], batch_size=100
)
class Migration(migrations.Migration):
dependencies = [
("db", "0046_auto_20230919_1421"),
]
operations = [
migrations.RunPython(update_priority_history),
]

View File

@ -26,7 +26,7 @@ ROLE_CHOICES = (
def get_default_props(): def get_default_props():
return { return {
"filters": { "filters": {
"priority": None, "priority": "none",
"state": None, "state": None,
"state_group": None, "state_group": None,
"assignees": None, "assignees": None,

View File

@ -17,7 +17,7 @@ ROLE_CHOICES = (
def get_default_props(): def get_default_props():
return { return {
"filters": { "filters": {
"priority": None, "priority": "none",
"state": None, "state": None,
"state_group": None, "state_group": None,
"assignees": None, "assignees": None,

View File

@ -74,10 +74,10 @@ def build_graph_plot(queryset, x_axis, y_axis, segment=None):
sorted_data = grouped_data sorted_data = grouped_data
if temp_axis == "priority": if temp_axis == "priority":
order = ["low", "medium", "high", "urgent", "None"] order = ["low", "medium", "high", "urgent", "none"]
sorted_data = {key: grouped_data[key] for key in order if key in grouped_data} sorted_data = {key: grouped_data[key] for key in order if key in grouped_data}
else: else:
sorted_data = dict(sorted(grouped_data.items(), key=lambda x: (x[0] == "None", x[0]))) sorted_data = dict(sorted(grouped_data.items(), key=lambda x: (x[0] == "none", x[0])))
return sorted_data return sorted_data

View File

@ -40,9 +40,6 @@ def filter_priority(params, filter, method):
priorities = params.get("priority").split(",") priorities = params.get("priority").split(",")
if len(priorities) and "" not in priorities: if len(priorities) and "" not in priorities:
filter["priority__in"] = priorities filter["priority__in"] = priorities
else:
if params.get("priority", None) and len(params.get("priority")):
filter["priority__in"] = params.get("priority")
return filter return filter