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