mozilla/olympia — pull request #254 by magopian (2014-09-04 11:17:53+00:00)
Title: Compute lightweight theme popularity and movers (bug 1059964)

Fixes [bug 1059964](https://bugzilla.mozilla.org/show_bug.cgi?id=1059964)

This PR is based on #252

I didn't find a way to optimise the average computation, by using annotations.
This means we'll run two "avg" aggregation queries for each theme, and then
save it (which means this will run 3 queries for each of the more than 200k
themes, everyday).

What would be nice would be to do something like:

```python
Addon.objects.annotate(Avg('theme_update_count__count'))
```

but find a way to filter that to only average on the ThemeUpdateCounts which
are at most 7 and 21 days old.