1
有沒有辦法將groupdate gem與動態參數一起用於數據解析?Rails:groupdate GEM變更組的分辨率動態參數
通常情況下,你可以使用
User.group_by_day(:created_at).count
或
User.group_by_week(:created_at).count
但我想通過參數使用天/周選項更改圖表。所以,我需要這樣的東西
User.group_by_groupdate(:created_at, resolution: params[:resolution]).count
其中PARAMS [:分辨率]可以是 「天」, 「周」, 「月」, 「年」,而不是做這樣的事情:
case params[:resolution]
when "day"
User.group_by_day(:created_at).count
when "week"
User.group_by_week(:created_at).count
end
謝謝! ..沒看到那個! – Alex