chore: changed view props

This commit is contained in:
NarayanBavisetti 2023-09-12 01:38:51 +05:30
parent 6867154963
commit 0713d4780d

View File

@ -0,0 +1,137 @@
# Generated by Django 4.2.3 on 2023-09-11 16:55
from django.db import migrations
def workspace_member_props(old_json):
new_json = {
"filters": {
"priority": old_json["filters"]["priority"] if "priority" in old_json["filters"] else None,
"state": old_json["filters"]["state"] if "state" in old_json["filters"] else None,
"state_group": old_json["filters"]["state_group"] if "state_group" in old_json["filters"] else None,
"assignees": old_json["filters"]["assignees"] if "assignees" in old_json["filters"] else None,
"created_by": old_json["filters"]["created_by"] if "created_by" in old_json["filters"] else None,
"labels": old_json["filters"]["labels"] if "labels" in old_json["filters"] else None,
"start_date": old_json["filters"]["start_date"] if "start_date" in old_json["filters"] else None,
"target_date": old_json["filters"]["target_date"] if "target_date" in old_json["filters"] else None,
"subscriber": old_json["filters"]["subscriber"] if "subscriber" in old_json["filters"] else None,
},
"display_filters": {
"group_by": old_json["groupByProperty"] if "groupByProperty" in old_json else None,
"order_by": old_json["orderBy"] if "orderBy" in old_json else "-created_at",
"type": old_json["filters"]["type"] if "type" in old_json["filters"] else None,
"sub_issue": old_json["showSubIssues"] if "sub_issue" in old_json["filters"] else True,
"show_empty_groups": old_json["showEmptyGroups"] if "showEmptyGroups" in old_json else True,
"layout": old_json["issueView"] if "issueView" in old_json else "list",
"calendar_date_range": old_json["calendarDateRange"] if "calendarDateRange" in old_json else "",
},
"display_properties": {
"assignee": old_json["properties"]["assignee"] if "assignee" in old_json["properties"] else None,
"attachment_count": old_json["properties"]["attachment_count"] if "attachment_count" in old_json["properties"] else None,
"created_on": old_json["properties"]["created_on"] if "created_on" in old_json["properties"] else None,
"due_date": old_json["properties"]["due_date"] if "due_date" in old_json["properties"] else None,
"estimate": old_json["properties"]["estimate"] if "estimate" in old_json["properties"] else None,
"key": old_json["properties"]["key"] if "key" in old_json["properties"] else None,
"labels": old_json["properties"]["labels"] if "labels" in old_json["properties"] else None,
"link": old_json["properties"]["link"] if "link" in old_json["properties"] else None,
"priority": old_json["properties"]["priority"] if "priority" in old_json["properties"] else None,
"start_date": old_json["properties"]["start_date"] if "start_date" in old_json["properties"] else None,
"state": old_json["properties"]["state"] if "state" in old_json["properties"] else None,
"sub_issue_count": old_json["properties"]["sub_issue_count"] if "sub_issue_count" in old_json["properties"] else None,
"updated_on": old_json["properties"]["updated_on"] if "updated_on" in old_json["properties"] else None,
},
}
return new_json
def project_member_props(old_json):
new_json = {
"filters": {
"priority": old_json["filters"]["priority"] if "priority" in old_json["filters"] else None,
"state": old_json["filters"]["state"] if "state" in old_json["filters"] else None,
"state_group": old_json["filters"]["state_group"] if "state_group" in old_json["filters"] else None,
"assignees": old_json["filters"]["assignees"] if "assignees" in old_json["filters"] else None,
"created_by": old_json["filters"]["created_by"] if "created_by" in old_json["filters"] else None,
"labels": old_json["filters"]["labels"] if "labels" in old_json["filters"] else None,
"start_date": old_json["filters"]["start_date"] if "start_date" in old_json["filters"] else None,
"target_date": old_json["filters"]["target_date"] if "target_date" in old_json["filters"] else None,
"subscriber": old_json["filters"]["subscriber"] if "subscriber" in old_json["filters"] else None,
},
"display_filters": {
"group_by": old_json["groupByProperty"] if "groupByProperty" in old_json else None,
"order_by": old_json["orderBy"] if "orderBy" in old_json else "-created_at",
"type": old_json["filters"]["type"] if "type" in old_json["filters"] else None,
"sub_issue": old_json["showSubIssues"] if "sub_issue" in old_json["filters"] else True,
"show_empty_groups": old_json["showEmptyGroups"] if "showEmptyGroups" in old_json else True,
"layout": old_json["issueView"] if "issueView" in old_json else "list",
"calendar_date_range": old_json["calendarDateRange"] if "calendarDateRange" in old_json else "",
},
}
return new_json
def cycle_module_props(old_json):
new_json = {
"filters": {
"priority": old_json["filters"]["priority"] if "priority" in old_json["filters"] else None,
"state": old_json["filters"]["state"] if "state" in old_json["filters"] else None,
"state_group": old_json["filters"]["state_group"] if "state_group" in old_json["filters"] else None,
"assignees": old_json["filters"]["assignees"] if "assignees" in old_json["filters"] else None,
"created_by": old_json["filters"]["created_by"] if "created_by" in old_json["filters"] else None,
"labels": old_json["filters"]["labels"] if "labels" in old_json["filters"] else None,
"start_date": old_json["filters"]["start_date"] if "start_date" in old_json["filters"] else None,
"target_date": old_json["filters"]["target_date"] if "target_date" in old_json["filters"] else None,
"subscriber": old_json["filters"]["subscriber"] if "subscriber" in old_json["filters"] else None,
},
}
return new_json
def update_workspace_member_view_props(apps, schema_editor):
WorkspaceMemberModel = apps.get_model("db", "WorkspaceMember")
updated_workspace_member = []
for obj in WorkspaceMemberModel.objects.all():
obj.view_props = workspace_member_props(obj.view_props)
obj.default_props = workspace_member_props(obj.default_props)
updated_workspace_member.append(obj)
WorkspaceMemberModel.objects.bulk_update(updated_workspace_member, ["view_props", "default_props"], batch_size=100)
def update_project_member_view_props(apps, schema_editor):
ProjectMemberModel = apps.get_model("db", "ProjectMember")
updated_project_member = []
for obj in ProjectMemberModel.objects.all():
obj.view_props = project_member_props(obj.view_props)
obj.default_props = project_member_props(obj.default_props)
updated_project_member.append(obj)
ProjectMemberModel.objects.bulk_update(updated_project_member, ["view_props", "default_props"], batch_size=100)
def update_cycle_props(apps, schema_editor):
CycleModel = apps.get_model("db", "Cycle")
updated_cycle = []
for obj in CycleModel.objects.all():
if "filter" in obj.view_props:
obj.view_props = cycle_module_props(obj.view_props)
updated_cycle.append(obj)
CycleModel.objects.bulk_update(updated_cycle, ["view_props"], batch_size=100)
def update_module_props(apps, schema_editor):
ModuleModel = apps.get_model("db", "Module")
updated_module = []
for obj in ModuleModel.objects.all():
if "filter" in obj.view_props:
obj.view_props = cycle_module_props(obj.view_props)
updated_module.append(obj)
ModuleModel.objects.bulk_update(updated_module, ["view_props"], batch_size=100)
class Migration(migrations.Migration):
dependencies = [
('db', '0042_alter_analyticview_created_by_and_more'),
]
operations = [
migrations.RunPython(update_workspace_member_view_props),
migrations.RunPython(update_project_member_view_props),
migrations.RunPython(update_cycle_props),
migrations.RunPython(update_module_props),
]