First version of the stats API: Number of submissions per country and per postal codes inside a country, with 3 first postal code characters as significant
Example output:
==> Request endpoint: stats
<== Response:
{
"success": true,
"data": {
"generated": "2020-04-19T13:23:15",
"submitters": {
"since": "2020-04-12T13:22:26",
"total": 10009,
"today": 9996,
"past_7_days": 10009
},
"submissions": {
"since": "2020-04-12T13:22:26",
"total": 210760,
"today": 131301,
"past_7_days": 210760
}
}
}
-----------------------------------------------------------------------
==> Request endpoint: stats?country=fi
<== Response:
{
"success": true,
"data": {
"generated": "2020-04-19T13:23:16",
"submitters": {
"since": "2020-04-12T13:22:27",
"total": 2508,
"today": 2504,
"past_7_days": 2508
},
"submissions": {
"since": "2020-04-12T13:22:27",
"total": 52841,
"today": 32926,
"past_7_days": 52841
}
}
}
-----------------------------------------------------------------------
==> Request endpoint: location
<== Response:
{
"success": true,
"data": {
"generated": "2020-04-19T13:23:17",
"submissions": {
"FI": 52841,
"IE": 52036,
"SE": 52587,
"US": 53296
}
}
}
-----------------------------------------------------------------------
==> Request endpoint: location/fi
<== Response:
{
"success": true,
"data": {
"generated": "2020-04-19T13:23:17",
"submissions": {
"201": 52839,
"331": 2
}
},
"country_code": "fi"
}
Testing
- Checkout this branch locally
- Standard dev environment with
docker-composer up --build
- Generate some test data with
make test-api
andmake test-data-generate
- Test the
stats
andapi
endpoints manually with curl or runmake test-api-stats
. - Add some more data manually and test more to see that the stats update as expected.
Edited by Otto Kekäläinen