Compare commits
2 Commits
6cb1f3aae5
...
de88475e40
Author | SHA1 | Date | |
---|---|---|---|
|
de88475e40 | ||
|
01a05c045d |
@ -33,7 +33,7 @@ def extract_unique_names_and_ids(data):
|
||||
|
||||
|
||||
def export_to_csv(unique_names, unique_ids):
|
||||
with open("output.csv", "w", newline="") as csvfile:
|
||||
with open("users.mapping.asana2ya.csv", "w", newline="") as csvfile:
|
||||
writer = csv.writer(csvfile, delimiter=",")
|
||||
writer.writerow(["Name", "ID"])
|
||||
|
||||
|
33
mapping.py
33
mapping.py
@ -1,22 +1,23 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
import requests
|
||||
from yandex_tracker_client import TrackerClient
|
||||
|
||||
|
||||
YANDEX_TRACKER_TOKEN = 'y0_AgAAAABAmFP8AArTqQAAAADyyFLmOoHqPprnRKag6B8okqjoDx2m9P0'
|
||||
ORG_ID = '35d164dcf81e48f2b6a532f4badddd33'
|
||||
|
||||
client = TrackerClient(
|
||||
token='YANDEX_TRACKER_TOKEN',
|
||||
org_id='ORG_ID'
|
||||
)
|
||||
|
||||
|
||||
YANDEX_TRACKER_TOKEN = 'y0_AgAEA7qkfTFqAArTqQAAAADyduv806rRKh8MS6GOg01ZdwPE-F4ZHuQ'
|
||||
ORG_ID = '35d164dcf81e48f2b6a532f4badddd33'
|
||||
|
||||
|
||||
base_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
asana_data_json = os.path.join(base_dir, './data/data_asana.json')
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
# ниже функция для случаев, когда не будет готового файла для импорта
|
||||
# def get_data_from_asana():
|
||||
@ -34,14 +35,14 @@ def transform_data(data):
|
||||
""" Преобразование данных из Asana в ЯндексТрекер в совместимом формате """
|
||||
|
||||
transformed_data = []
|
||||
for task in data:
|
||||
for task in data["data"]:
|
||||
transformed_task = {
|
||||
'summary': task['name'],
|
||||
'description': task['notes'],
|
||||
'createdAt': task['created_at'],
|
||||
'deadline': task['due_on'],
|
||||
'assignee': task['assignee'],
|
||||
'milestone': task['section'],
|
||||
# 'milestone': task['section'],
|
||||
# 'memberships': task['memberships'],
|
||||
# 'parent': task[''],
|
||||
'status': task['completed'],
|
||||
@ -55,7 +56,7 @@ def create_tasks_in_tracker(data):
|
||||
|
||||
base_url = 'https://api.tracker.yandex.net/v2/issues'
|
||||
headers = {
|
||||
'Authorization': 'YANDEX_TRACKER_TOKEN',
|
||||
'Authorization': 'ORG_ID',
|
||||
'Content-Type': 'asana_data_json',
|
||||
}
|
||||
for task in data:
|
||||
@ -65,7 +66,7 @@ def create_tasks_in_tracker(data):
|
||||
'createdAt': task['createdAt'],
|
||||
'deadline': task['deadline'],
|
||||
'assignee': task['assignee'],
|
||||
'milestone': task['milestone'],
|
||||
# 'milestone': task['milestone'],
|
||||
# 'memberships': task['memberships'],
|
||||
# 'parent': task['parent'],
|
||||
'status': task['status'],
|
||||
@ -84,15 +85,9 @@ def create_tasks_in_tracker(data):
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
""" Основная функция для переноса данных """
|
||||
# asana_data = get_data_from_asana()
|
||||
with open(asana_data_json, 'r') as file:
|
||||
asana_data = json.load(file)
|
||||
# return asana_data
|
||||
yandex_tracker_data = transform_data(asana_data)
|
||||
file = open(asana_data_json, "r", encoding="utf8")
|
||||
json_data = json.loads(file.read())
|
||||
|
||||
yandex_tracker_data = transform_data(json_data)
|
||||
create_tasks_in_tracker(yandex_tracker_data)
|
||||
|
||||
|
||||
# Запуск основной функции
|
||||
main()
|
||||
|
9
users.mapping.asana2ya.csv
Normal file
9
users.mapping.asana2ya.csv
Normal file
@ -0,0 +1,9 @@
|
||||
Name,ID
|
||||
IrinaOs,698025068994499
|
||||
Сергей Анисов,547756841476
|
||||
Илья,2495641457848
|
||||
Malkova,1204278463134045
|
||||
Sergey Volodin,1202859655765863
|
||||
Никита,1203071663735925
|
||||
Cyrill Gafarov,2934206415688
|
||||
Diza,2495641457856
|
|
Loading…
Reference in New Issue
Block a user