Use with groupdate results in time objects as keys (instead of date objects)
abinoda opened this issue · 3 comments
abinoda commented
When using with groupdate, the median
method results in keys that are time objects, whereas with average
, the keys are date objects. This then results in the chartkick labels showing times 😢
query.group_by_period(:month, :submitted_at).average(:time)
=> {Sun, 01 Apr 2018=>0.128564313333333333e6, Tue, 01 May 2018=>0.180389867753623188e6, Fri, 01 Jun 2018=>0.185993985959438378e6, Sun, 01 Jul 2018=>0.168664401069518717e6, Wed, 01 Aug 2018=>0.209151385899814471e6, Sat, 01 Sep 2018=>0.140354274944567627e6}
query.group_by_period(:month, :submitted_at).median(:time)
=> {2018-04-01 00:00:00 UTC=>46613.5, 2018-05-01 00:00:00 UTC=>51045.5, 2018-06-01 00:00:00 UTC=>26603.0, 2018-07-01 00:00:00 UTC=>39185.0, 2018-08-01 00:00:00 UTC=>15291.0, 2018-09-01 00:00:00 UTC=>24202.0}
abinoda commented
Sorry, my original example was wrong. Just corrected it.
abinoda commented
That fixed it, thanks!