Skip to content

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

Otto Kekäläinen requested to merge feature/api-stats-v1 into master

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

  1. Checkout this branch locally
  2. Standard dev environment with docker-composer up --build
  3. Generate some test data with make test-api and make test-data-generate
  4. Test the stats and api endpoints manually with curl or run make test-api-stats.
  5. Add some more data manually and test more to see that the stats update as expected.
Edited by Otto Kekäläinen

Merge request reports