refactor(mappping): set the limit for task creation

This commit is contained in:
Angelina Tingaeva 2023-12-07 16:44:29 +05:00
parent bb26424787
commit de1be5a536

View File

@ -85,7 +85,7 @@ def transform_data(data):
return transformed_data return transformed_data
def create_tasks_in_tracker(data): def create_tasks_in_tracker(data, limit=10):
""" Создание задач в ЯндексТрекер """ """ Создание задач в ЯндексТрекер """
base_url = 'https://api.tracker.yandex.net/v2/issues/_import' base_url = 'https://api.tracker.yandex.net/v2/issues/_import'
@ -95,13 +95,14 @@ def create_tasks_in_tracker(data):
'X-Org-ID': '7095769', 'X-Org-ID': '7095769',
'Content-Type': 'appication/json', 'Content-Type': 'appication/json',
} }
datalen = len(data) datalen = min(limit, len(data))
logger.info('Import started. Task count: %d', datalen) logger.info('Import started. Task count: %d', datalen)
# этот датасет тоже для parent добавлен # этот датасет тоже для parent добавлен
ya_imported_task_response = {} ya_imported_task_response = {}
for task in data: for i in range(datalen):
task = data[i]
if task.get('assignee') and 'gid' in task['assignee']: if task.get('assignee') and 'gid' in task['assignee']:
ya_assignee = assignee.get(task['assignee']['gid'], 'dr.cyrill') ya_assignee = assignee.get(task['assignee']['gid'], 'dr.cyrill')
@ -187,4 +188,4 @@ file = open(asana_data_json, "r", encoding="utf8")
json_data = json.loads(file.read()) json_data = json.loads(file.read())
yandex_tracker_data = transform_data(json_data) yandex_tracker_data = transform_data(json_data)
create_tasks_in_tracker(yandex_tracker_data) create_tasks_in_tracker(yandex_tracker_data, limit=10)