wri/forma-api — pull request #32 by robinkraft (2013-06-21 23:37:38+00:00)
Title: fill in incomplete time series with zeros

Fixes #26 and #14.

http://wip.forma-api.appspot.com/api/counts/BRA/1/10?range=2009-01-01,2009-02-03

```json
{
"country":"Brazil",
"data":[
{
"id":10,
"series":[
[
"2009-01-01",
0
],
[
"2009-01-17",
2
],
[
"2009-02-02",
0
]
],
"name":"M\u00e2ncio Lima",
"level":2
}
],
"iso":"BRA",
"sql":"SELECT sub.iso, name0, sub.id1, sub.id2, sub.name0, sub.name1, sub.name2, '[' || trim(Array_agg(to_char(sub.date, 'YYYY-MM-DD'))::text, '{}\"') || ']' dates, '[' || trim(Array_agg(sub.alerts)::text, '{}\"') || ']' alerts FROM (SELECT iso, id1, id2, name0, name1, name2, date, sum(alerts) alerts FROM forma WHERE iso = 'BRA' AND id1 = 1 AND id2 = 10 AND date >= '2009-01-01' AND date <= '2009-02-03' GROUP BY iso, id1, id2, name0, name1, name2, date ORDER BY date ASC) sub GROUP BY sub.iso, name0, sub.id1, sub.id2, sub.name0, sub.name1, sub.name2"
}
```