我正在使用groupdate gem在event_start_time上按日分组事件,这是一个Rails日期时间对象。无论如何,我可以覆盖group_by_day
函数来返回包含事件对象的哈希的哈希。
根据文档,这是按日分组时获得的哈希值。
User.group_by_day(:created_at).count # { # 2013-04-16 00:00:00 UTC => 50, # 2013-04-17 00:00:00 UTC => 100, # 2013-04-18 00:00:00 UTC => 34 # }
如果我想要返回一个哈希,如下例所示。
User.group_by_day(:created_at).count { 2013-04-16 00:00:00 UTC => { id: "1", location: "Sf",.., }, 2013-04-17 00:00:00 UTC => { id: "40", location: "Gt",.., }, 2013-04-18 00:00:00 UTC => { id: "100", location: "SD",..,} }
在我看来,我想按天分组显示这些事件。提前谢谢。