Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created March 10, 2014 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enjalot/9457496 to your computer and use it in GitHub Desktop.
Save enjalot/9457496 to your computer and use it in GitHub Desktop.
commonwealth: crunchbase
{"description":"commonwealth: crunchbase","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"inline-console":true,"thumbnail":"http://i.imgur.com/t2XqWy6.png"}
var query = "select funded_year, funded_month, \
sum(raised_amount) raised, count(*) funding_rounds \
from crunchbase.funding \
where funded_year >= 2000 \
and raised_amount is not null \
and funded_year is not null \
and funded_month is not null \
group by funded_year, funded_month \
order by funded_year desc, funded_month desc \
limit 1000;"
var url = queryToURL(query);
console.log(url);
d3.json(url, function(err, data) {
console.log(err)
console.log(data);
})
function queryToURL(q) {
var regex = new RegExp("(\\s)+","g")
var qstr = q.replace(regex,"%20");
return "http://commonwealth.io/api/v1/postgres?query=" + qstr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment