Published
Edited
Oct 6, 2021
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
table = Inputs.table(data_10k, {})
Insert cell
Insert cell
Insert cell
Insert cell
function myFilter(arr,objField){
// subfunction to transform row to object type
function toObj(row) {
return JSON.parse(row.DATA)
}

// iterate of input array of objects
var output_arr = []
arr.forEach( element => output_arr.push(toObj(element)[objField]) )
return output_arr
}
Insert cell
Insert cell
function getEmail(arr) {
return myFilter(arr,"author_email")
}
Insert cell
Insert cell
Insert cell
function groupByVolume(arr) {
var singleObj = arr.reduce(function (allObjects, obj) {
if (obj in allObjects) {
allObjects[obj].volume++
}
else {
allObjects[obj] = {email:obj,volume:1}
}
return allObjects
}, [])
// return order by descending
return Object.values(singleObj).sort((a, b) => {
return b.volume - a.volume;
})
}
Insert cell
groupedEmails = groupByVolume(getEmail(data_50k))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function generateContributorOrgObject(groupedEmails){
var output = []
groupedEmails.forEach(row => output.push({contributor:row.email,org:String(row.email).split("@")[1],commits:row.volume}))
return output
}
Insert cell
Insert cell
Inputs.table(contributor_org_object, {})
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more