mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: estimate point value in graph
This commit is contained in:
parent
e53ce860f9
commit
7f99c95830
@ -33,7 +33,7 @@ class AnalyticsEndpoint(BaseAPIView):
|
|||||||
"state__group",
|
"state__group",
|
||||||
"labels__id",
|
"labels__id",
|
||||||
"assignees__id",
|
"assignees__id",
|
||||||
"estimate_point",
|
"estimate_point__value",
|
||||||
"issue_cycle__cycle_id",
|
"issue_cycle__cycle_id",
|
||||||
"issue_module__module_id",
|
"issue_module__module_id",
|
||||||
"priority",
|
"priority",
|
||||||
|
121
apiserver/plane/db/migrations/0067_auto_20240605_0837.py
Normal file
121
apiserver/plane/db/migrations/0067_auto_20240605_0837.py
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
# # Generated by Django 4.2.7 on 2024-05-24 09:47
|
||||||
|
# Python imports
|
||||||
|
import uuid
|
||||||
|
from uuid import uuid4
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
def issue_estimate_point(apps, schema_editor):
|
||||||
|
Issue = apps.get_model("db", "Issue")
|
||||||
|
Project = apps.get_model("db", "Project")
|
||||||
|
EstimatePoint = apps.get_model("db", "EstimatePoint")
|
||||||
|
IssueActivity = apps.get_model("db", "IssueActivity")
|
||||||
|
updated_estimate_point = []
|
||||||
|
updated_issue_activity = []
|
||||||
|
|
||||||
|
# loop through all the projects
|
||||||
|
for project in Project.objects.filter(estimate__isnull=False):
|
||||||
|
estimate_points = EstimatePoint.objects.filter(
|
||||||
|
estimate=project.estimate, project=project
|
||||||
|
)
|
||||||
|
|
||||||
|
for issue_activity in IssueActivity.objects.filter(
|
||||||
|
field="estimate_point", project=project
|
||||||
|
):
|
||||||
|
if issue_activity.new_value:
|
||||||
|
new_identifier = estimate_points.filter(
|
||||||
|
key=issue_activity.new_value
|
||||||
|
).first().id
|
||||||
|
issue_activity.new_identifier = new_identifier
|
||||||
|
new_value = estimate_points.filter(
|
||||||
|
key=issue_activity.new_value
|
||||||
|
).first().value
|
||||||
|
issue_activity.new_value = new_value
|
||||||
|
|
||||||
|
if issue_activity.old_value:
|
||||||
|
old_identifier = estimate_points.filter(
|
||||||
|
key=issue_activity.old_value
|
||||||
|
).first().id
|
||||||
|
issue_activity.old_identifier = old_identifier
|
||||||
|
old_value = estimate_points.filter(
|
||||||
|
key=issue_activity.old_value
|
||||||
|
).first().value
|
||||||
|
issue_activity.old_value = old_value
|
||||||
|
updated_issue_activity.append(issue_activity)
|
||||||
|
|
||||||
|
for issue in Issue.objects.filter(
|
||||||
|
point__isnull=False, project=project
|
||||||
|
):
|
||||||
|
# get the estimate id for the corresponding estimate point in the issue
|
||||||
|
estimate = estimate_points.filter(key=issue.point).first()
|
||||||
|
issue.estimate_point = estimate
|
||||||
|
updated_estimate_point.append(issue)
|
||||||
|
|
||||||
|
Issue.objects.bulk_update(
|
||||||
|
updated_estimate_point, ["estimate_point"], batch_size=1000
|
||||||
|
)
|
||||||
|
IssueActivity.objects.bulk_update(
|
||||||
|
updated_issue_activity,
|
||||||
|
["new_value", "old_value", "new_identifier", "old_identifier"],
|
||||||
|
batch_size=1000,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def last_used_estimate(apps, schema_editor):
|
||||||
|
Project = apps.get_model("db", "Project")
|
||||||
|
Estimate = apps.get_model("db", "Estimate")
|
||||||
|
|
||||||
|
# Get all estimate ids used in projects
|
||||||
|
estimate_ids = Project.objects.filter(estimate__isnull=False).values_list(
|
||||||
|
"estimate", flat=True
|
||||||
|
)
|
||||||
|
|
||||||
|
# Update all matching estimates
|
||||||
|
Estimate.objects.filter(id__in=estimate_ids).update(last_used=True)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("db", "0066_account_id_token_cycle_logo_props_module_logo_props"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="estimate",
|
||||||
|
name="last_used",
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
# Rename the existing field
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name="issue",
|
||||||
|
old_name="estimate_point",
|
||||||
|
new_name="point",
|
||||||
|
),
|
||||||
|
# Add a new field with the original name as a foreign key
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="issue",
|
||||||
|
name="estimate_point",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.SET_NULL,
|
||||||
|
related_name="issue_estimates",
|
||||||
|
to="db.EstimatePoint",
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="estimate",
|
||||||
|
name="type",
|
||||||
|
field=models.CharField(default="categories", max_length=255),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="estimatepoint",
|
||||||
|
name="value",
|
||||||
|
field=models.CharField(max_length=255),
|
||||||
|
),
|
||||||
|
migrations.RunPython(issue_estimate_point),
|
||||||
|
migrations.RunPython(last_used_estimate),
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user