Skip to content

Instantly share code, notes, and snippets.

@JohnRiv
Created April 25, 2012 13:58
Show Gist options
  • Save JohnRiv/2489913 to your computer and use it in GitHub Desktop.
Save JohnRiv/2489913 to your computer and use it in GitHub Desktop.
Reviewboard "Reviewed By" Data
import requests
# If you don't have requests installed, installation instructions are at http://docs.python-requests.org/en/v0.10.7/user/install/
urls = ['URLS_FROM_reviewData.js_GO_HERE']
cookies = dict(rbsessionid='PASTE_YOUR_COOKIE_VAL_HERE')
reviewed = 0
notreviewed = 0
for url in urls:
r = requests.get(url, cookies=cookies)
str1 = r.text[r.text.lower().find("reviewed by"):]
str = str1[:str1.find("\n")]
str = str.lower().strip()
print url
if str == "" or str == "reviewed by:" or str == "reviewed by: none" or str == "reviewed by: n/a":
notreviewed = notreviewed + 1
print "\033[0;31mNo Review!\033[0;m"
else:
reviewed = reviewed + 1
print "\033[0;32m" + str + "\033[0;m"
print ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ."
print "\033[0;32mAdditional Reviews: \033[0;m"
print reviewed
print "\033[0;31mChangesets not reviewed:\033[0;m"
print notreviewed
function evalRbDate(ds) {
ds = $.trim(ds).replace("th,",",").replace("nd,",",").replace("rd,",",").replace("st,",",");
ds = ds.substring(0,ds.lastIndexOf(","));
return new Date(ds);
}
function rowInDateRange(node,startDate,endDate) {
if(startDate) {
endDate = endDate || "01 01 2100";
endDate = new Date(endDate);
startDate = new Date(startDate);
var rbDate = evalRbDate(node);
if(rbDate <= endDate && rbDate >= startDate) {
return true;
} else {
return false;
}
} else {
return true;
}
}
function reviewData(reviewCol,summaryCol,dateCol,startDate,endDate) {
var user = window.location.href.split("/")[4];
var r = { reviews: 0, ships: [], tbd: []};
var str = "";
var inSprint = true;
$(".datagrid td.summary").each(function() {
if(dateCol) {
inSprint = rowInDateRange($($(this).siblings()[dateCol]).text(),startDate,endDate);
} else {
inSprint = true;
}
if(inSprint === true) {
if($.trim($($(this).siblings()[reviewCol]).text()) > 0) {
str = $.trim($(this).text());
r.ships.push(str.substring(0,str.indexOf(":")));
} else {
str = $.trim($(this).html());
str = str.substring(str.indexOf('"')+1);
r.tbd.push("'http://cim-review.dev.cim.comcast.net" + str.substring(0,str.indexOf('"')) + "'");
}
r.reviews++;
}
});
console.log(user + " has " + r.reviews + " commits, with " + r.ships.length + " of them reviewed.");
console.log("Check these reviews directly: ")
return "urls = [" + r.tbd + "]";
}
reviewData(2,3,4,"10 08 2012","10 19 2012");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment