From 8376b28fc59fe16804e29f348a4f271402a94efa Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Mon, 8 Jul 2024 16:22:36 +0530 Subject: [PATCH 1/3] fix: cycle transfer activity --- apiserver/plane/app/views/cycle/base.py | 44 ++++++++++++++++++++----- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/apiserver/plane/app/views/cycle/base.py b/apiserver/plane/app/views/cycle/base.py index 65d65e5257b..25b83a272d9 100644 --- a/apiserver/plane/app/views/cycle/base.py +++ b/apiserver/plane/app/views/cycle/base.py @@ -465,14 +465,14 @@ def list(self, request, slug, project_id): } if data[0]["start_date"] and data[0]["end_date"]: - data[0]["estimate_distribution"]["completion_chart"] = ( - burndown_plot( - queryset=queryset.first(), - slug=slug, - project_id=project_id, - plot_type="points", - cycle_id=data[0]["id"], - ) + data[0]["estimate_distribution"][ + "completion_chart" + ] = burndown_plot( + queryset=queryset.first(), + slug=slug, + project_id=project_id, + plot_type="points", + cycle_id=data[0]["id"], ) assignee_distribution = ( @@ -1507,14 +1507,40 @@ def post(self, request, slug, project_id, cycle_id): ) updated_cycles = [] + update_cycle_issue_activity = [] for cycle_issue in cycle_issues: - cycle_issue.cycle_id = new_cycle_id updated_cycles.append(cycle_issue) + update_cycle_issue_activity.append( + { + "old_cycle_id": str(cycle_id), + "new_cycle_id": str(new_cycle_id), + "issue_id": str(cycle_issue.issue_id), + } + ) + cycle_issue.cycle_id = new_cycle_id cycle_issues = CycleIssue.objects.bulk_update( updated_cycles, ["cycle_id"], batch_size=100 ) + # Capture Issue Activity + issue_activity.delay( + type="cycle.activity.created", + requested_data=json.dumps({"cycles_list": []}), + actor_id=str(self.request.user.id), + issue_id=None, + project_id=str(self.kwargs.get("project_id", None)), + current_instance=json.dumps( + { + "updated_cycle_issues": update_cycle_issue_activity, + "created_cycle_issues": "[]", + } + ), + epoch=int(timezone.now().timestamp()), + notification=True, + origin=request.META.get("HTTP_ORIGIN"), + ) + return Response({"message": "Success"}, status=status.HTTP_200_OK) From e56e9bbb3f5cae015d3c7ee8fc7e2ad191169d69 Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Mon, 8 Jul 2024 19:39:27 +0530 Subject: [PATCH 2/3] chore: external api transfer issue --- apiserver/plane/api/serializers/cycle.py | 6 +++--- apiserver/plane/api/views/cycle.py | 26 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/apiserver/plane/api/serializers/cycle.py b/apiserver/plane/api/serializers/cycle.py index 6fc73a4bc7e..d03af1a8b27 100644 --- a/apiserver/plane/api/serializers/cycle.py +++ b/apiserver/plane/api/serializers/cycle.py @@ -13,9 +13,9 @@ class CycleSerializer(BaseSerializer): started_issues = serializers.IntegerField(read_only=True) unstarted_issues = serializers.IntegerField(read_only=True) backlog_issues = serializers.IntegerField(read_only=True) - total_estimates = serializers.IntegerField(read_only=True) - completed_estimates = serializers.IntegerField(read_only=True) - started_estimates = serializers.IntegerField(read_only=True) + total_estimates = serializers.FloatField(read_only=True) + completed_estimates = serializers.FloatField(read_only=True) + started_estimates = serializers.FloatField(read_only=True) def validate(self, data): if ( diff --git a/apiserver/plane/api/views/cycle.py b/apiserver/plane/api/views/cycle.py index a95a4d5f464..8b9f90de5ff 100644 --- a/apiserver/plane/api/views/cycle.py +++ b/apiserver/plane/api/views/cycle.py @@ -1140,12 +1140,38 @@ def post(self, request, slug, project_id, cycle_id): ) updated_cycles = [] + update_cycle_issue_activity = [] for cycle_issue in cycle_issues: cycle_issue.cycle_id = new_cycle_id updated_cycles.append(cycle_issue) + update_cycle_issue_activity.append( + { + "old_cycle_id": str(cycle_id), + "new_cycle_id": str(new_cycle_id), + "issue_id": str(cycle_issue.issue_id), + } + ) cycle_issues = CycleIssue.objects.bulk_update( updated_cycles, ["cycle_id"], batch_size=100 ) + # Capture Issue Activity + issue_activity.delay( + type="cycle.activity.created", + requested_data=json.dumps({"cycles_list": []}), + actor_id=str(self.request.user.id), + issue_id=None, + project_id=str(self.kwargs.get("project_id", None)), + current_instance=json.dumps( + { + "updated_cycle_issues": update_cycle_issue_activity, + "created_cycle_issues": "[]", + } + ), + epoch=int(timezone.now().timestamp()), + notification=True, + origin=request.META.get("HTTP_ORIGIN"), + ) + return Response({"message": "Success"}, status=status.HTTP_200_OK) From c7e1a59657447dc6e3efe229ac7b2b5fbfaac9f9 Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Mon, 8 Jul 2024 19:44:40 +0530 Subject: [PATCH 3/3] chore: moved the cycle id --- apiserver/plane/app/views/cycle/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apiserver/plane/app/views/cycle/base.py b/apiserver/plane/app/views/cycle/base.py index 25b83a272d9..2583913aa57 100644 --- a/apiserver/plane/app/views/cycle/base.py +++ b/apiserver/plane/app/views/cycle/base.py @@ -1509,6 +1509,7 @@ def post(self, request, slug, project_id, cycle_id): updated_cycles = [] update_cycle_issue_activity = [] for cycle_issue in cycle_issues: + cycle_issue.cycle_id = new_cycle_id updated_cycles.append(cycle_issue) update_cycle_issue_activity.append( { @@ -1517,7 +1518,6 @@ def post(self, request, slug, project_id, cycle_id): "issue_id": str(cycle_issue.issue_id), } ) - cycle_issue.cycle_id = new_cycle_id cycle_issues = CycleIssue.objects.bulk_update( updated_cycles, ["cycle_id"], batch_size=100