Commit 051641f8ab915352718856e4e7227209deab4ba5
1 parent
6f6837bc
Exists in
master
and in
17 other branches
Easier to read output
Showing
1 changed file
with
20 additions
and
4 deletions
Show diff stats
README.md
... | ... | @@ -16,13 +16,25 @@ PostgreSQL only at the moment - support for other datastores coming soon |
16 | 16 | |
17 | 17 | ```ruby |
18 | 18 | User.group_by_day(:created_at).count |
19 | -# => {"2013-04-16 00:00:00+00" => 50, "2013-04-17 00:00:00+00" => 100} | |
19 | +# { | |
20 | +# "2013-04-16 00:00:00+00" => 50, | |
21 | +# "2013-04-17 00:00:00+00" => 100, | |
22 | +# "2013-04-18 00:00:00+00" => 34 | |
23 | +# } | |
20 | 24 | |
21 | 25 | Task.group_by_month(:updated_at).count |
22 | -# => {"2013-03-01 00:00:00+00" => 23, "2013-04-01 00:00:00+00" => 44} | |
26 | +# { | |
27 | +# "2013-02-01 00:00:00+00" => 84, | |
28 | +# "2013-03-01 00:00:00+00" => 23, | |
29 | +# "2013-04-01 00:00:00+00" => 44 | |
30 | +# } | |
23 | 31 | |
24 | 32 | Goal.group_by_year(:accomplished_at).count |
25 | -# => {"2012-01-01 00:00:00+00" => 11, "2013-01-01 00:00:00+00" => 3} | |
33 | +# { | |
34 | +# "2011-01-01 00:00:00+00" => 7, | |
35 | +# "2012-01-01 00:00:00+00" => 11, | |
36 | +# "2013-01-01 00:00:00+00" => 3 | |
37 | +# } | |
26 | 38 | ``` |
27 | 39 | |
28 | 40 | The default time zone is `Time.zone`. Pass a time zone as the second argument. |
... | ... | @@ -30,7 +42,11 @@ The default time zone is `Time.zone`. Pass a time zone as the second argument. |
30 | 42 | ```ruby |
31 | 43 | time_zone = ActiveSupport::TimeZone["Pacific Time (US & Canada)"] |
32 | 44 | User.group_by_week(:created_at, time_zone).count |
33 | -# => {"2013-04-16 07:00:00+00" => 80, "2013-04-17 07:00:00+00" => 70} | |
45 | +# { | |
46 | +# "2013-02-25 08:00:00+00" => 80, | |
47 | +# "2013-03-04 08:00:00+00" => 70, | |
48 | +# "2013-03-11 07:00:00+00" => 54 | |
49 | +# } | |
34 | 50 | ``` |
35 | 51 | |
36 | 52 | Use it with anything you can use `group` with: | ... | ... |