DB aggregation for downloads stats

I moved the aggregation into the database.
Still need to test this, so please don't merge, just wanted to get an early feedback.
I didn't know you could drop the `req` from the parameter list. That's kind of cool.