Skip to content

Instantly share code, notes, and snippets.

@codeimpossible
Created June 13, 2012 00:52
Show Gist options
  • Save codeimpossible/2921095 to your computer and use it in GitHub Desktop.
Save codeimpossible/2921095 to your computer and use it in GitHub Desktop.
get number of closed questions from stackoverflow for a certain tag
function showStats(tag_name) {
var script = document.createElement("scr" + "ipt");
script.src = "https://api.stackexchange.com/2.0/questions?fromdate=1336780800&todate=1339459200&order=desc&sort=activity&tagged=" + tag_name + "&site=stackoverflow&callback=renderStats";
console.log(script);
$('body').append( script );
}
window.renderStats=function( json ) {
var num_closed = 0;
for(var i = -1, l = json.items.length; ++i < l; ) {
var item = json.items[i];
if(item.is_answered) {
num_closed++;
}
}
$('#stats').html( num_closed + " questions answered in last 30 days");
};
showStats('ruby-on-rails');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment