Last active
March 4, 2019 08:25
-
-
Save mixj93/1490a082088647c5fead78b574a707af to your computer and use it in GitHub Desktop.
JIRA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 上周总结 | |
function collectionHas(a, b) { //helper function (see below) | |
for(var i = 0, len = a.length; i < len; i ++) { | |
if(a[i] == b) return true; | |
} | |
return false; | |
} | |
function findParent(elm, selector) { | |
var all = document.querySelectorAll(selector); | |
var cur = elm.parentNode; | |
while(cur && !collectionHas(all, cur)) { //keep going up until you find a match | |
cur = cur.parentNode; //go up | |
} | |
return cur; //will return null if not found | |
} | |
function buildIssueText(issue, userID) { | |
return ` | |
<ac:structured-macro ac:macro-id="90c3685d-a0f5-4f02-9a5d-c36141868b78" ac:name="jira" ac:schema-version="1"> | |
<ac:parameter ac:name="server">JIRA</ac:parameter> | |
<ac:parameter ac:name="serverId">60348d1e-4a8c-3a79-9693-ee08b4ed20f8</ac:parameter> | |
<ac:parameter ac:name="key">${issue}</ac:parameter> | |
</ac:structured-macro> | |
<ac:link> | |
<ri:user ri:userkey="${userID}"/> | |
</ac:link> | |
` | |
} | |
let res = '<br/>'; | |
let issues = document.querySelectorAll('div.ghx-issue'); | |
let columnMap = { | |
"3051": "todo", | |
"3054": "doing", | |
"3057": "done" | |
}; | |
// let userMap = { | |
// "changkun": "常坤", | |
// "chenkaijun": "陈凯俊", | |
// "duzhanwei": "杜占伟", | |
// "lixueli": "李雪瓅", | |
// "lutao": "路涛", | |
// "mali": "马力", | |
// "yuanzihua": "袁子华", | |
// "zhangbo01": "张波" | |
// }; | |
let userMap = { | |
"changkun": "ff808081644c59e40164631d26c70026", | |
"chenkaijun": "ff80808156f32b8f0157ccc0a9bb0023", | |
"duzhanwei": "ff8080815e2aa5ac015ea8d22f61001d", | |
"lixueli": "ff8080815409c362015427755b190193", | |
"lutao": "ff8080815e2aa5ac015e3ce39157000a", | |
"mali": "ff8080816393f48c0163bb7e14690026", | |
"sunjingqi": "2c94743e6625a27601668c6b966e0019", | |
"yangshuo": "ff808081593d9f80015aa164b704001a", | |
"yuanzihua": "ff8080815ef8a423015f8ba609770016", | |
"zhangbo01": "ff8080816393f48c0163e37006940043" | |
}; | |
let delays = []; | |
let dones = []; | |
for (let i = 0; i < issues.length; i++) { | |
let issue = issues[i]; | |
let key = issue.querySelector('.js-key-link').innerText; | |
let url = issue.querySelector('.js-key-link').href; | |
let title = issue.querySelector('.ghx-summary').title; | |
let assignee = userMap[findParent(issue, ".ghx-swimlane").querySelector(".ghx-heading span[role='button']").innerText] | |
let columnId = findParent(issue, ".ghx-column").getAttribute("data-column-id") | |
switch (columnId) { | |
case "3057": | |
dones.push({key, url, title, assignee, columnId}) | |
break; | |
default: | |
delays.push({key, url, title, assignee, columnId}) | |
break; | |
} | |
} | |
res += '<br/>DELAYED<br/>'; | |
res += '<br/>'; | |
for (let i = 0; i < delays.length; i++) { | |
let d = delays[i]; | |
res += `${buildIssueText(d.key, d.assignee)}<br/>` | |
} | |
res += '<br/>DONE<br/>'; | |
res += '<br/>'; | |
for (let i = 0; i < dones.length; i++) { | |
let d = dones[i]; | |
res += `${buildIssueText(d.key, d.assignee)}<br/>` | |
} | |
res += '<br/>' | |
console.log(res) | |
copy(res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment