refactor(mapping): refactor updating data and create messages about updating yandex tracker data with parent task
This commit is contained in:
parent
007ca43a43
commit
528e76f3ee
@ -17,7 +17,8 @@ def setup_logging(name):
|
|||||||
file_handler = logging.FileHandler(
|
file_handler = logging.FileHandler(
|
||||||
filename=f"{name}.log",
|
filename=f"{name}.log",
|
||||||
mode='w',
|
mode='w',
|
||||||
encoding='utf-8'
|
encoding='utf-8',
|
||||||
|
delay=True
|
||||||
)
|
)
|
||||||
file_handler.setLevel(logging.DEBUG)
|
file_handler.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
15
mapping.py
15
mapping.py
@ -131,6 +131,9 @@ def create_tasks_in_tracker(data):
|
|||||||
parent_task_gid = task['parent']['gid']
|
parent_task_gid = task['parent']['gid']
|
||||||
if parent_task_gid in ya_imported_task_response:
|
if parent_task_gid in ya_imported_task_response:
|
||||||
parent_task_id = ya_imported_task_response[parent_task_gid]['id']
|
parent_task_id = ya_imported_task_response[parent_task_gid]['id']
|
||||||
|
logger.debag(
|
||||||
|
f'В задаче {task['summary']} есть связка "parent"'
|
||||||
|
)
|
||||||
update_parent_task(
|
update_parent_task(
|
||||||
base_url,
|
base_url,
|
||||||
headers,
|
headers,
|
||||||
@ -145,9 +148,19 @@ def update_parent_task(base_url, headers, task_id, parent_task_id):
|
|||||||
payload = {
|
payload = {
|
||||||
'parent': parent_task_id
|
'parent': parent_task_id
|
||||||
}
|
}
|
||||||
|
|
||||||
update_url = f"{base_url}/{task_id}"
|
update_url = f"{base_url}/{task_id}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = requests.post(update_url, headers=headers, data=payload)
|
||||||
|
|
||||||
|
if response.status_code == 200:
|
||||||
|
print('Данные успешно обновлены с добавлением нового элемента.')
|
||||||
|
else:
|
||||||
|
print('Ошибка при обновлении данных.')
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as error:
|
||||||
|
print('Произошла ошибка при обновлении данных:', error)
|
||||||
|
|
||||||
|
|
||||||
# asana_data = get_data_from_asana()
|
# asana_data = get_data_from_asana()
|
||||||
file = open(asana_data_json, "r", encoding="utf8")
|
file = open(asana_data_json, "r", encoding="utf8")
|
||||||
|
Loading…
Reference in New Issue
Block a user