Created
January 3, 2013 22:02
-
-
Save groovecoder/4447792 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<script> | |
var states = ['selected', 'analysis', 'story', 'implement', 'review', 'test', 'released'], | |
ghBugs = [], | |
bzBugs = [], | |
kanBugs = {}; | |
_.each(states, function(state) { | |
kanBugs[state] = []; | |
}); | |
//console.log(kanBugs); | |
var loadGhBugs = function(data) { | |
_.each(data, function(pull){ | |
var bugRE = /fix bug (\d+)/; | |
var bugArray = bugRE.exec(pull.title); | |
if (bugArray && typeof(bugArray[1]) != undefined) { | |
//console.log("Pull " + pull.number + " fixes bug " + bugID); | |
var bugID = bugArray[1]; | |
var ghBug = {id: bugID, state: pull.state, created_at: pull.created_at, merged_at: pull.merged_at}; | |
ghBugs.push(ghBug); | |
} | |
}); | |
}; | |
var processBzBugs = function(data) { | |
/* | |
console.log("processBzBugs"); | |
console.log("data.bugs: " + JSON.stringify(data.bugs)); | |
*/ | |
_.each(data.bugs, function(bug){ | |
//console.log("bug:" + JSON.stringify(bug)); | |
var li = "<li><a href=\"https://bugzilla.mozilla.org/show_bug.cgi?id=" + bug.id + "\" target=\"_blank\">" + bug.id + "</a><br/>" + bug.summary + "</li>"; | |
var $storyList = $('ul#story'); | |
var $implementList = $('ul#implement'); | |
var $reviewList = $('ul#review'); | |
var $testList = $('ul#test'); | |
var $releasedList = $('ul#released'); | |
// Start from the right of the board and work left | |
if (bug.status == 'VERIFIED') { | |
kanBugs['released'].push(bug); | |
$releasedList.append(li); | |
} else if (bug.status == 'RESOLVED') { | |
kanBugs['test'].push(bug) | |
$testList.append(li); | |
// Check the list of GitHub bugs to see if a pull request is in for the bug | |
} else if (_.contains(_.pluck(ghBugs, 'id'), bug.id.toString())){ | |
kanBugs['review'].push(bug); | |
$reviewList.append(li); | |
} else if (bug.assigned_to.name) { | |
kanBugs['implement'].push(bug); | |
$implementList.append(li); | |
} else { | |
kanBugs['selected'].push(bug); | |
var $selectedList = $('ul#selected'); | |
$selectedList.append(li); | |
} | |
//console.log("Bug " + bug.id); | |
}); | |
//console.log(kanBugs); | |
}; | |
// Get MDN pull requests from GitHub | |
var githubURL = "https://api.github.com/repos/mozilla/kuma/pulls"; | |
var gettingPulls = $.getJSON(githubURL, { | |
client_id: '6f879db8324dca8c26f1', | |
client_secret: 'da455accd2ff34dbbc52697c7649f49b717ec98d' | |
}); | |
$.when(gettingPulls.done(loadGhBugs)); | |
// Get bugs from Bugzilla | |
var bugzillaURL = "https://api-dev.bugzilla.mozilla.org/latest/bug" + | |
"?product=Mozilla%20Developer%20Network" + | |
"&include_fields=id,summary,component,creation_time,creator,status,resolution,whiteboard,assigned_to,depends_on,blocks,history" + | |
"&whiteboard=kanbugs"; | |
var gettingBugs = $.getJSON(bugzillaURL); | |
$.when(gettingBugs).done(processBzBugs); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment