refactor(mapping): add task_tatus
This commit is contained in:
parent
8546782a22
commit
3c6221ad90
17
mapping.py
17
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,
|
||||
|
Loading…
Reference in New Issue
Block a user