Skip to content

Instantly share code, notes, and snippets.

@robinkraft
Last active December 18, 2015 12:48
Show Gist options
  • Save robinkraft/5784896 to your computer and use it in GitHub Desktop.
Save robinkraft/5784896 to your computer and use it in GitHub Desktop.
Sample output (sans name fields) for API. The first object is the output coming from CartoDB, while the second is the final output the user will see, after post-processing with Python. This is current as of https://github.com/wri/forma-api/commit/7fbfa35b453ec13ef7978c697716e8cab66346da
{
"url": "localhost:8080/api/counts/idn/10/91?range=2006-01-01,2010-01-01"
}
{
"time":0.056,
"sql":"SELECT id1,id2,iso,'[' || trim(Array_agg(to_char(date, 'YYYY-MM-DD'))::text, '{}\"') || ']' dates,'[' || trim(Array_agg(alerts)::text, '{}') || ']' sum FROM forma_gadm_50 WHERE iso='IDN' AND id1=10 AND id2=91 AND date >= '2006-01-01' AND date <= '2010-01-01' GROUP BY id1,id2,iso",
"total_rows":1,
"rows":[
{
"id1":10,
"sum":"[2,1,2,1,1,2,1,1,4,4,3,1,1,2,1,1,1,1,2,5,1,2,1,2,5,2,3,5,4,8,1,9,1,1,1,2,1,1,4,1,1]",
"id2":91,
"dates":"[2006-01-17,2006-03-06,2006-07-12,2006-07-28,2006-08-13,2006-08-29,2006-09-14,2006-09-30,2006-11-01,2006-11-17,2006-12-03,2006-12-19,2007-01-01,2007-01-17,2007-02-02,2007-03-06,2007-08-13,2007-08-29,2007-10-16,2007-11-01,2007-11-17,2007-12-19,2008-01-01,2008-02-02,2008-06-09,2008-07-27,2008-08-12,2008-08-28,2008-09-13,2008-09-29,2008-10-15,2008-10-31,2008-11-16,2008-12-02,2008-12-18,2009-03-06,2009-03-22,2009-09-30,2009-11-01,2009-11-17,2009-12-03]",
"iso":"IDN"
}
]
}
{
"admin1":{
"id":10
},
"data":[
{
"series":[
[
"2006-03-06",
1
],
[
"2006-07-12",
2
],
[
"2006-07-28",
1
],
[
"2006-08-13",
1
],
[
"2006-08-29",
2
],
[
"2006-09-14",
1
],
[
"2006-09-30",
1
],
[
"2006-11-01",
4
],
[
"2006-11-17",
4
],
[
"2006-12-03",
3
],
[
"2006-12-19",
1
],
[
"2007-01-01",
1
],
[
"2007-01-17",
2
],
[
"2007-02-02",
1
],
[
"2007-03-06",
1
],
[
"2007-08-13",
1
],
[
"2007-08-29",
1
],
[
"2007-10-16",
2
],
[
"2007-11-01",
5
],
[
"2007-11-17",
1
],
[
"2007-12-19",
2
],
[
"2008-01-01",
1
],
[
"2008-02-02",
2
],
[
"2008-06-09",
5
],
[
"2008-07-27",
2
],
[
"2008-08-12",
3
],
[
"2008-08-28",
5
],
[
"2008-09-13",
4
],
[
"2008-09-29",
8
],
[
"2008-10-15",
1
],
[
"2008-10-31",
9
],
[
"2008-11-16",
1
],
[
"2008-12-02",
1
],
[
"2008-12-18",
1
],
[
"2009-03-06",
2
],
[
"2009-03-22",
1
],
[
"2009-09-30",
1
],
[
"2009-11-01",
4
],
[
"2009-11-17",
1
]
],
"id":91,
"level":2
}
],
"iso":"IDN"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment