Public
Edited
Oct 20, 2023
Insert cell
Insert cell
query = function(q, token, url) {
const opts = {
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `token ${token}`,
},
method: 'post',
body: JSON.stringify({query: q})
};
return fetch(url, opts).then(r=>r.json())
}
Insert cell
gh_url = `https://api.github.com/graphql`
Insert cell
import {secret} from "@tmcw/secret"
Insert cell
viewof gh_token = secret("gh_token", {
submit: "Submit token"
})
Insert cell
q = `
query {
search(type: USER, query: "location:\\"Santa Fe\\"", first:100) {
userCount
edges {
node {
...on User {
login
company
}
}
}
}
}`
Insert cell
result = query(q, gh_token, gh_url)
Insert cell
data = result.data.search.edges.map(x => x.node).filter(x => x.company != null)
Insert cell
_.chain(data)
.groupBy('company')
.pickBy(users => users.length > 1)
.sortBy(users => users.length)
.value()
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