views:

20

answers:

0

I'm trying to use a slightly more interesting GROUP BY cause than what seems to be supported out of the box by DataMapper.

The query I want to generate looks something like this:

SELECT SUM(downloads), SUM(uploads) FROM daily_stats GROUP BY YEARWEEK(date)

I'd like to be able to just tell DataMapper something along these lines:

DailyStat.aggregate(:downloads.sum, :uploads.sum, :fields => [ :date.yearweek ])

Where would I begin? Is this easily achievable?