refactor(mapping): try to create mapping for parent tasks
This commit is contained in:
parent
f6a7724f4e
commit
9f7a57e8aa
30
mapping.py
30
mapping.py
@ -2,7 +2,7 @@ import csv
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
# import logging
|
||||
|
||||
import requests
|
||||
|
||||
@ -44,6 +44,7 @@ def get_assignee_data():
|
||||
mapping[asana_id] = ya_login
|
||||
return mapping
|
||||
|
||||
|
||||
assignee = get_assignee_data()
|
||||
|
||||
|
||||
@ -109,7 +110,7 @@ def create_tasks_in_tracker(data):
|
||||
# 'completedAt': task['completedAt']
|
||||
}
|
||||
|
||||
logger.debug('Запрос: %s', json.dumps(payload))
|
||||
# logger.debug('Запрос: %s', json.dumps(payload))
|
||||
|
||||
response = requests.post(
|
||||
base_url,
|
||||
@ -124,7 +125,30 @@ def create_tasks_in_tracker(data):
|
||||
'Ошибка при создании задачи в ЯндексТрекер:',
|
||||
response.content,
|
||||
)
|
||||
logger.debug('Ответ: %s', response.content)
|
||||
# logger.debug('Ответ: %s', response.content)
|
||||
|
||||
ya_imported_task_response = response.json()
|
||||
if task.get('parent'):
|
||||
parent_task_gid = task['parent']['gid']
|
||||
if parent_task_gid in ya_imported_task_response:
|
||||
parent_task_id = ya_imported_task_response[parent_task_gid]['id']
|
||||
update_parent_task(
|
||||
base_url,
|
||||
headers,
|
||||
ya_imported_task_response['id'],
|
||||
parent_task_id,
|
||||
)
|
||||
|
||||
|
||||
def update_parent_task(base_url, headers, task_id, parent_task_id):
|
||||
""" Обновление данных родительской задачи в ЯндексТрекере"""
|
||||
|
||||
payload = {
|
||||
'parent': parent_task_id
|
||||
}
|
||||
|
||||
update_url = f"{base_url}/{task_id}"
|
||||
|
||||
|
||||
# asana_data = get_data_from_asana()
|
||||
file = open(asana_data_json, "r", encoding="utf8")
|
||||
|
Loading…
Reference in New Issue
Block a user