From d2212a001a81be657de6c704f023b9460cca5e47 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Wed, 12 Jul 2023 00:15:40 +0530 Subject: [PATCH] dev: update archival structure for auto close issues --- .../plane/bgtasks/issue_activites_task.py | 26 +++++++++++++++++++ .../plane/bgtasks/issue_automation_task.py | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/apiserver/plane/bgtasks/issue_activites_task.py b/apiserver/plane/bgtasks/issue_activites_task.py index 6d7d6c0d7..c05442163 100644 --- a/apiserver/plane/bgtasks/issue_activites_task.py +++ b/apiserver/plane/bgtasks/issue_activites_task.py @@ -591,6 +591,31 @@ def track_archive_at( ) +def track_closed_to( + requested_data, current_instance, issue_id, project, actor, issue_activities +): + if requested_data.get("closed_to") is not None: + updated_state = State.objects.get( + pk=requested_data.get("closed_to"), project=project + ) + + issue_activities.append( + IssueActivity( + issue_id=issue_id, + actor=actor, + verb="updated", + old_value=None, + new_value=updated_state.name, + field="state", + project=project, + workspace=project.workspace, + comment=f"Plane updated the state to {updated_state.name}", + old_identifier=None, + new_identifier=updated_state.id, + ) + ) + + def update_issue_activity( requested_data, current_instance, issue_id, project, actor, issue_activities ): @@ -608,6 +633,7 @@ def update_issue_activity( "blockers_list": track_blockings, "estimate_point": track_estimate_points, "archived_at": track_archive_at, + "closed_to": track_closed_to, } requested_data = json.loads(requested_data) if requested_data is not None else None diff --git a/apiserver/plane/bgtasks/issue_automation_task.py b/apiserver/plane/bgtasks/issue_automation_task.py index b0405b98a..0fb6943ca 100644 --- a/apiserver/plane/bgtasks/issue_automation_task.py +++ b/apiserver/plane/bgtasks/issue_automation_task.py @@ -130,7 +130,7 @@ def close_old_issues(): [ issue_activity.delay( type="issue.activity.updated", - requested_data=json.dumps({"state": issue.state}), + requested_data=json.dumps({"closed_to": issue.state_id}), actor_id=str(project.created_by_id), issue_id=issue.id, project_id=project_id,