Advertisement
TheShestov

Untitled

Nov 24th, 2019
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.65 KB | None | 0 0
  1. //include "inclusions/zube/zube_getUserJira.sil";
  2. include "inclusions/zube/zube_epicLink.sil";
  3. include "inclusions/zube/zube_getPostComments.sil";
  4. include "inclusions/zube/zube_insertImage.sil";
  5.  
  6. string json = readFromTextFile("Admin_Scripts/zube/Json/1158.json");
  7. json = replace(json, "number", "number_");
  8.  
  9. struct Labels {
  10. string id;
  11. string name;
  12. string color;
  13. string project_id;
  14. }
  15.  
  16. // struct Label_ids {
  17. // string id;
  18. // }
  19.  
  20.  
  21. struct Epic {
  22. number id;
  23. //string workspace_id;
  24. //string status;
  25. //string color;
  26. //string title;
  27. }
  28. /*
  29. struct Creator {
  30. number id;
  31. string username;
  32. string name;
  33. }*/
  34.  
  35. struct Assignees {
  36. number id;
  37. string username;
  38. string name;
  39. string avatar_path;
  40. }
  41.  
  42. struct zube {
  43. //string sprint_id;
  44. number id; //customfield_10219 ++
  45. string creator_id; //reporter ++
  46. //string project_id; //один у всех
  47. //string workspace_id; //один у всех
  48. string body; //дескрипшин ++
  49. string category_name; //похоже на статус
  50. string closed_at; //дата закрытия (НУЖНО ПОЛЕ) ++
  51. string comments_count; //счетчик комментов
  52. //string last_comment_at; //дата последнего комментария не интересна
  53. string number_; //номер в системе customfield_10220 ++
  54. string points; //СториПоинты ++
  55. string priority; //++
  56. //string search_key;
  57. string state; //или open или closed ++
  58. string status; //доступные: done, in_review, queued ++
  59. string title; //summary ++
  60. //string upvotes_count; //хз. везде ноль
  61. string created_at; //++
  62. //string updated_at; //не интересна
  63. string epic_id; //
  64. //string closer_id; //тот кто закрыл(сомневаюсь, что важно)
  65. //string was_archived_from_404; //null
  66. Epic epic;
  67. Creator creator;
  68. Labels labels;
  69. //Label_ids label_ids; //дичь какая-то/ один айдишник
  70. Assignees [] assignees;
  71. }
  72.  
  73. zube [] cData = fromJson(json);
  74. int count = 0;
  75.  
  76. string pKey = "GUIDIMPORT";
  77. string parentIssueKey = "";
  78. string issueType = "Task";
  79. string summary = "";
  80. string priority = "";
  81. string description = "";
  82. string components = "";
  83. date dueDate;
  84. interval estimate;
  85. string sLevel;
  86.  
  87. for(zube zb in cData){
  88.  
  89. string [] custom_field_mapping;
  90.  
  91. //работа с Assignee
  92. if(isNotNull(zb.assignees[0].id)){
  93.  
  94. custom_field_mapping = addElement(custom_field_mapping, "assignee");
  95.  
  96. if(zube_getUserJira(zb.assignees[0].id) == ""){
  97. runnerLog("не найден ASSIGNEE: " + zb.assignees[0].id);
  98. runnerLog("number: " + zb.number_);
  99. custom_field_mapping = addElement(custom_field_mapping, "robot");
  100.  
  101. }
  102. else {
  103. custom_field_mapping = addElement(custom_field_mapping, zube_getUserJira(zb.assignees[0].id));
  104. }
  105.  
  106. }
  107. //работа с Creator
  108. if(isNotNull(zb.creator_id)){
  109. custom_field_mapping = addElement(custom_field_mapping, "reporter");
  110. if(zube_getUserJira(zb.creator_id) == ""){
  111. runnerLog("не найден CREATOR: " + zb.creator_id);
  112. runnerLog("number: " + zb.number_);
  113. custom_field_mapping = addElement(custom_field_mapping, "Robot");
  114. }
  115. else {
  116. custom_field_mapping = addElement(custom_field_mapping, zube_getUserJira(zb.creator_id));
  117. }
  118. }
  119. //работа с labels
  120. if(isNotNull(zb.labels)){
  121. custom_field_mapping += {"labels",zb.labels.name};
  122. }
  123.  
  124. //Добавляем epic_id в поле
  125. if(zb.epic_id != ""){
  126. custom_field_mapping +={"customfield_10224",zb.epic_id};
  127. }
  128.  
  129. custom_field_mapping += {"customfield_10219",zb.id,"customfield_10220",zb.number_,"customfield_10221",zb.created_at};
  130.  
  131. //closed_at
  132. if(zb.closed_at != ""){
  133. custom_field_mapping += {"customfield_10222",zb.closed_at};
  134. }
  135. //Description
  136. description = zb.body;
  137. //runnerLog(zb.body);
  138.  
  139. //Приоритеты
  140. switch(zb.priority){
  141. case "5":
  142. priority = "Trivial";
  143. break;
  144. case "4":
  145. priority = "Low";
  146. break;
  147. case "3":
  148. priority = "Medium";
  149. break;
  150. case "2":
  151. priority = "High";
  152. break;
  153. case "1":
  154. priority = "Blocker";
  155. break;
  156. default:
  157. priority = "Medium";
  158. }
  159.  
  160. //StoryPoints
  161. if(zb.points != 0 && zb.points != ""){
  162. custom_field_mapping += {"customfield_10106",zb.points};
  163. }
  164.  
  165. //issueType
  166. if(isNotNull(zb.labels)){
  167. if(zb.labels.name == "Bug" || zb.labels.name == "bug"){
  168. issueType = "Bug";
  169. }
  170. else{
  171. issueType = "Task";
  172. }
  173. }
  174. else{
  175. issueType = "Task";
  176. }
  177.  
  178. string k = createIssue(
  179. pKey,
  180. parentIssueKey,
  181. issueType,
  182. zb.title,
  183. priority,
  184. description,
  185. components,
  186. dueDate,
  187. estimate,
  188. sLevel,
  189. custom_field_mapping
  190. );
  191. if(zb.status == "in_progress"){
  192. autotransition(61, k, true, true, true);
  193. }
  194. else if(zb.status == "completed"){
  195. autotransition(81, k, true, true, true);
  196. }
  197. else if(zb.status == "done"){
  198. autotransition(81, k, true, true, true);
  199. }
  200. else if(zb.status == "in_review"){
  201. autotransition(71, k, true, true, true);
  202. }
  203. else if(zb.status == "queued"){
  204. autotransition(61, k, true, true, true);
  205. }
  206. //done, in_review, queued
  207.  
  208. if(zb.state == "closed"){
  209. autotransition(81, k, true, true, true);
  210. }
  211.  
  212. //Comments
  213. if(zb.comments_count != "0"){
  214. // функция обработки комментов
  215. zube_getPostComments(k, zb.id);
  216.  
  217. }
  218. /*вывыв*/
  219. //Epics
  220. if(zb.epic_id != ""){
  221. //функция обработки тасок с эпиками
  222. zube_epicLink(k, zb.epic_id);
  223. }
  224.  
  225. //нужны релейтед
  226.  
  227.  
  228.  
  229. //Добавление аттачей из дескрипшина
  230. zube_insertImage(k, description);
  231.  
  232.  
  233. runnerLog("Создано: " + k);
  234.  
  235. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement