From 3c6221ad908f5223c62c01a5536e807f02b603db Mon Sep 17 00:00:00 2001 From: Angelina Tingaeva Date: Wed, 29 Nov 2023 14:08:36 +0500 Subject: [PATCH] refactor(mapping): add task_tatus --- mapping.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mapping.py b/mapping.py index 1c9f4d9..7bfb879 100644 --- a/mapping.py +++ b/mapping.py @@ -43,17 +43,32 @@ def get_assignee_data(): assignee = get_assignee_data() +def get_task_status(task): + """ Получение данных о статусе задачи """ + + if task.get('completed') is True: + status = 'resolved' + completed_at = task.get('completed_at', '') + else: + status = 'open' + completed_at = '' + return status, completed_at + + def transform_data(data): """ Преобразование данных из Asana в ЯндексТрекер в совместимом формате """ transformed_data = [] for task in data["data"]: + status, completed_at = get_task_status(task) transformed_task = { 'summary': task['name'], 'description': task['notes'], 'createdAt': task['created_at'], 'deadline': task['due_on'], 'assignee': task['assignee'], + 'status': status, + 'completedAt': completed_at, } transformed_data.append(transformed_task) return transformed_data @@ -86,7 +101,7 @@ def create_tasks_in_tracker(data): # 'milestone': task['milestone'], # 'memberships': task['memberships'], # 'parent': task['parent'], - # 'status': task['status'], + 'status': task['status'], } response = requests.post( base_url,