mozilla/kitsune — pull request #1545 by rlr (2013-08-05 14:06:33+00:00)
Title: API for WikiMetrics data

@willkg f?

This is a pretty basic API that uses most of what DRT provides out of the box (model serializers, pagination, generic view, etc.). As a result, the output looks very much like a row of stored data:

```
"results": [
{
"code": "active_contributors",
"locale": "es",
"product": null,
"date": "2012-07-01",
"value": 6.0
},
```

That's great, but I think it may be useful to group the rows by date. Something like this:

```
"results": [
{
"locale": "es",
"product": null,
"date": "2012-07-01",
"active_contributors": 6.0,
"percent_localized_all": 6.0,
"percent_localized_top20": 6.0,
...
},
```

To do this, we would pretty much have to ditch a ton of the freebies we are getting from DRT and just write a view that returns an array of dict that looks like the results we want. I don't think we'd be able to use serializers because they assume 1:1 - one object to one row of results. Also, pagination is super tricky since we are combining multiple db rows into one row of results.

Is it OK to go with the simple API call for now and later add a new method that does grouping? Should we jump right into it now? I'm on the fence...

To play with the API, go to:

http://localhost:8000/api/v1/wikimetrics/

You can do filtering, for example:
http://localhost:8000/api/v1/wikimetrics/?locale=es
http://localhost:8000/api/v1/wikimetrics/?locale=de&code=active_contributors
http://localhost:8000/api/v1/wikimetrics/?code=active_contributors&product=firefox

etc.