fix(mapping): numerous fixes in specs and mappings

This commit is contained in:
cyrill 2023-11-27 17:18:51 +05:00
parent a1e86ba7bf
commit 5c037fe68d

View File

@ -36,7 +36,7 @@ sys.stdout.reconfigure(encoding='utf-8')
# return data
def get_assignee_data(data):
def get_assignee_data():
""" Получение данных для поля assignee """
mapping = {}
@ -44,12 +44,12 @@ def get_assignee_data(data):
with open(users_data, 'r', encoding="utf8") as csv_file:
reader = csv.DictReader(csv_file)
for row in reader:
asana_id = row[1]
ya_login = row[2]
asana_id = row['ID']
ya_login = row['ya_login']
mapping[asana_id] = ya_login
return mapping
assignee = value for value in mapping[asana_id]
assignee = get_assignee_data()
def transform_data(data):
@ -62,7 +62,7 @@ def transform_data(data):
'description': task['notes'],
'createdAt': task['created_at'],
'deadline': task['due_on'],
# 'assignee': task['assignee'],
'assignee': task['assignee'],
# 'milestone': task['section'],
# 'memberships': task['memberships'],
# 'parent': task[''],
@ -78,22 +78,24 @@ def create_tasks_in_tracker(data):
base_url = 'https://api.tracker.yandex.net/v2/issues'
headers = {
'Host': 'api.tracker.yandex.net',
'Authorization': 'OAuth y0_AgAAAABAmFP8AArTqQAAAADyyFLmOoHqPprnRKag6B8okqjoDx2m9P0',
'Authorization': 'OAuth y0_AgAEA7qkB3KjAArTqQAAAADzHp7Ut0nhAmx5Q_25b1jpqiuBXRIJksk',
'X-Org-ID': '7095769',
'Content-Type': 'appication/json',
}
for task in data:
ya_assignee = assignee[task['assignee']['gid']] if task.get('assignee',0)!=0 else 'dr.cyrill@heado.ru'
payload = {
'queue': 'TESTIMPORT', # Вынести в переменную
'summary': task['summary'],
'description': task['description'],
'createdAt': task['createdAt'],
'createdBy': 'dr.cyrill@heado.ru',
'deadline': task['deadline'],
'assignee': assignee,
'assignee': ya_assignee,
# 'milestone': task['milestone'],
# 'memberships': task['memberships'],
# 'parent': task['parent'],
'status': task['status'],
#'status': task['status'],
}
response = requests.post(
base_url,
@ -107,6 +109,7 @@ def create_tasks_in_tracker(data):
'Ошибка при создании задачи в ЯндексТрекер:',
response.content,
)
exit()
# asana_data = get_data_from_asana()