Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

280 lines (242 sloc) 6.857 kb
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Basecamp Blockers</title>
<link rel="stylesheet" href="bootstrap.min.css">
<script type='text/javascript' src='jquery-1.7.1.min.js'></script>
<script type='text/javascript' src='jquery.isotope.min.js'></script>
<script type="text/javascript" src="bugzilla.js"></script>
<script type="text/javascript" src="github.js"></script>
<script type="text/javascript" src="mustache.js" ></script>
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 9pt;
margin: 0 auto;
background-image: -moz-radial-gradient(center 45deg, circle closest-side, #fff 0%, #DDD 140%);
background-attachment: fixed;
text-align: left;
}
#controls {
float: left;
}
label {
width: 200px;
}
.ray {
background-color: rgba(255,255,255,.1);
width: 150%;
height: 10px;
position: fixed;
top: 50%;
left: -25%;
-moz-transform:
-moz-transform-origin: 100% 50%;
z-index: -1;
}
.main {
width: 100%;
}
.page-header {
margin-left: 0.5em;
}
.widget {
text-align: center;
height: 10em;
width: 15em;
clear: both;
padding-top: 2em;
margin: 10px;
border-radius: 0.5em;
background: rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.bugCount {
text-align: center;
}
.bugCount > h1 {
font-size: 6em;
}
.bugList {
text-align: left;
}
.bugList ul {
margin: 0;
}
</style>
</head>
<body>
<div>
<h1>Basecamp Blockers</h1>
</div>
<div id="controls"><input type="checkbox" id="loe"><label>bugs w/o LOE estimate</label></div>
<br clear="all">
<div id='feedback' style='text-align: center;'></div>
<br clear="all">
<div class="main container-fluid">
<div id="container"></div>
</div>
<script>
var main = document.querySelector('.main')
var feedback = document.querySelector('#feedback')
// bugzilla search options for all basecamp+ bugs
var defaultSearchOpts = {
'bug_status': ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"],
'field0-0-0': 'cf_blocking_basecamp',
'type0-0-0': 'equals',
'value0-0-0': '+'
}
// bugzilla search options for all basecamp+ bugs without LOE estimates
var loeSearchOpts = {
'bug_status': ["NEW", "UNCONFIRMED", "ASSIGNED", "REOPENED"],
'field0-0-0': 'cf_blocking_basecamp',
'type0-0-0': 'equals',
'value0-0-0': '+',
'field1-0-0': 'whiteboard',
'type1-0-0': 'not_contains',
'value1-0-0': '[LOE:',
}
// helper for seaching bugzilla
function bugSearch(type) {
this.type = type
}
bugSearch.prototype = {
fetch: function(options, callback) {
var url = (this.type == 'bug') ? '/bug' : '/count';
Bugzilla.ajax({
url: url,
data: options,
success: function(data) {
callback(data.data || data.bugs);
}
});
}
}
// helper for searching github
function issueSearch() {
}
issueSearch.prototype = {
fetch: function(options, callback) {
Github.user = 'mozilla-b2g'
Github.repo = 'gaia'
var results = []
options.page = 1
function driver() {
Github.search(options, function(someResults) {
if (someResults.length) {
results = results.concat(someResults)
options.page++
setTimeout(driver, 0)
}
else
callback(results)
})
}
driver()
}
}
// user feedback message with spinner
// pass empty string to clear
function progress(msg) {
if (!msg)
feedback.innerHTML = ''
else
feedback.innerHTML = "<img src='http://www.fbi.gov/spinner.gif'><br>" + msg
}
// clear visible results and do a new search
function reload(searchOpts) {
// remove previous container
main.removeChild(document.querySelector('#container'))
// create new container
var container = document.createElement('div')
container.setAttribute('id', 'container')
main.appendChild(container)
// update user feedback to indicate progress
progress('Searching Bugzilla...');
var bzSearchOpts = searchOpts.noLOE ? loeSearchOpts : defaultSearchOpts
new bugSearch('bug').fetch(bzSearchOpts, function(results) {
//progress('');
//displayResults(results)
progress('Searched Bugzilla, now searching Github...');
// now do github search
var issuesOptions = {
per_page: 100,
labels: 'blocking-basecamp+'
}
new issueSearch().fetch(issuesOptions, function(githubResults) {
if (searchOpts.noLOE) {
githubResults = githubResults.filter(function(issue) {
return issue.labels.every(function(label) {
return !(/\[LOE:/.test(label.name));
})
})
}
results = results.concat(githubResults)
progress('');
displayResults(results)
})
})
}
// given a blank container and an array of results,
// process and write to main container
function displayResults(results) {
// aggregate bugs per user
var names = {}
var i = 0
results.forEach(function(bug) {
// convert github to bugzilla
if (bug.user) {
bug.assigned_to = bug.user
bug.assigned_to.name = bug.user.login
bug.assigned_to.real_name = bug.user.login
bug.assigned_to.url = 'https://github.com/mozilla-b2g/gaia/issues/search?q=&state=open&assignee=' + bug.user.login + '&labels=blocking-basecamp%2b'
}
else
bug.assigned_to.url = 'https://bugzilla.mozilla.org/buglist.cgi?quicksearch=@' + bug.assigned_to.name + ' blocking-basecamp:%2b'
if (!names[bug.assigned_to.real_name])
names[bug.assigned_to.real_name] = { user: bug.assigned_to, count: 1}
else
names[bug.assigned_to.real_name].count++
i++
});
feedback.innerHTML = results.length + ' Results';
var container = document.querySelector('#container')
for (var name in names) {
var template =
"<div class='widget' id='{{_id}}'>"
+ "<div class='bugCount'>"
+ "<h1>{{count}}</h1><br clear=all>"
+ "<a href='{{url}}' target='new'>"
+ "<div>{{title}}</div>"
+ "</a>"
+ "</div>"
+ "</div>";
container.innerHTML += Mustache.to_html(template, {
url: names[name].user.url,
count: names[name].count,
title: name
});
}
$('#container').isotope({
itemSelector : '.widget',
sortBy : 'bugCount',
sortAscending : false,
layoutMode : 'fitRows',
getSortData : {
bugCount : function ( $elem ) {
return parseInt($elem.find('.bugCount').text(), 10);
}
}
});
}
// LOE checkbox
var loe = document.querySelector('#loe')
loe.addEventListener('change', function() {
loe.checked ? reload({noLOE: true}) : reload({})
})
// load default search
reload({})
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.