Last active
April 26, 2024 22:58
-
-
Save juliandescottes/2ecfec21a9d40c8c00a6a88e312d9f67 to your computer and use it in GitHub Desktop.
Debugger release metrics
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
"use strict"; | |
(function () { | |
const BUGZILLA_API_URL = "https://bugzilla.mozilla.org"; | |
const BUG_URL = BUGZILLA_API_URL + "/rest/bug/${BUG_ID}"; | |
const COMMENTS_URL = BUGZILLA_API_URL + "/rest/bug/${BUG_ID}/comment"; | |
const HISTORY_URL = BUGZILLA_API_URL + "/rest/bug/${BUG_ID}/history"; | |
const TRY_URL = "https://treeherder.mozilla.org"; | |
let RELEASE_BUG_IDS = [ | |
1416960, | |
1428455, | |
1434769, | |
1416358, | |
1430855, | |
1423158, | |
1411727, | |
1433117, | |
1429908, | |
1432842, | |
1429599, | |
1426462, | |
1419801, | |
1425876, | |
1425912, | |
1429238, | |
1438014, | |
1434025, | |
1436893, | |
1436210, | |
1438930, | |
1427187, | |
1415300, | |
1428925, | |
1439763, | |
1440550, | |
1441635, | |
1445081, | |
1445496, | |
1446234, | |
1446501, | |
1446959, | |
1447682, | |
1448193, | |
1449049, | |
1449362, | |
1449611, | |
1450112, | |
]; | |
async function getBugDetails(bugid) { | |
let headers = new Headers(); | |
headers.append("Accept", "application/json"); | |
let response = await fetch(BUG_URL.replace("${BUG_ID}", bugid), { | |
mode: "cors", | |
method: "GET", | |
headers | |
}); | |
let json = await response.json(); | |
return json.bugs[0]; | |
} | |
async function getBugComments(bugid) { | |
let headers = new Headers(); | |
headers.append("Accept", "application/json"); | |
let response = await fetch(COMMENTS_URL.replace("${BUG_ID}", bugid), { | |
mode: "cors", | |
method: "GET", | |
headers | |
}); | |
let json = await response.json(); | |
return json.bugs[bugid].comments; | |
} | |
async function getBugHistory(bugid) { | |
let headers = new Headers(); | |
headers.append("Accept", "application/json"); | |
let response = await fetch(HISTORY_URL.replace("${BUG_ID}", bugid), { | |
mode: "cors", | |
method: "GET", | |
headers | |
}); | |
let json = await response.json(); | |
return json.bugs[0].history; | |
} | |
async function getBugInfo(bugid) { | |
let getDetails = getBugDetails(bugid); | |
let getComments = getBugComments(bugid); | |
let getHistory = getBugHistory(bugid); | |
let details = await getDetails; | |
let comments = await getComments; | |
let history = await getHistory; | |
// try runs | |
let tryRuns = comments.filter(comment => comment.raw_text.includes(TRY_URL)).length; | |
// duration | |
let duration = new Date(details.cf_last_resolved) - new Date(details.creation_time); | |
let hours = Math.floor(duration / (1000 * 3600)); | |
hours = hours % 24; | |
let days = Math.floor(duration / (24 * 3600 * 1000)); | |
// reviews | |
let changes = history.reduce((p,n) => p.concat(n.changes), []); | |
let reviewsAsked = changes.filter(c => c.added.includes("review?")); | |
let reviewsGranted = changes.filter(c => c.added.includes("review+")); | |
let meta = { | |
tryRuns, | |
time: `${days}d ${hours}h`, | |
duration: (duration/(24 * 3600 * 1000)).toFixed(3), | |
comments: comments.length, | |
reviews: {asked: reviewsAsked.length, granted: reviewsGranted.length} | |
}; | |
return {bugid, meta, title: details.summary, details, comments, history}; | |
} | |
function toCSV(infos) { | |
let buffer = ["Bugid, title, duration, since, comments, try runs, r?, r+"]; | |
for (let info of infos) { | |
let {bugid, title, meta, since} = info; | |
buffer.push( | |
`${bugid}, ${title}, ${meta.duration}, ${since}, ${meta.comments}, ${meta.tryRuns}, ${meta.reviews.asked}, ${meta.reviews.granted}`); | |
} | |
return buffer.join("\n"); | |
} | |
async function run() { | |
let infos = []; | |
for (let bugid of RELEASE_BUG_IDS) { | |
let info = await getBugInfo(bugid); | |
infos.push(info); | |
} | |
infos = infos.sort((i1, i2) => { | |
return i1.bugid - i2.bugid; | |
}); | |
infos.forEach((info, i) => { | |
if (i == 0) { | |
info.since = 0; | |
return; | |
} | |
let previous = infos[i-1]; | |
let since = new Date(info.details.creation_time) - new Date(previous.details.creation_time); | |
info.since = (since/(24 * 3600 * 1000)).toFixed(3); | |
}); | |
console.log(infos); | |
console.log(toCSV(infos)) | |
} | |
run(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment