Sha256: 19e7fc96c8cb999b735b15c413c11498dd5a21d60339b0997273309a104683cc
Contents?: true
Size: 732 Bytes
Versions: 13
Compression:
Stored size: 732 Bytes
Contents
module ForestLiana class PieStatGetter attr_accessor :record def initialize(resource, params) @resource = resource @params = params end def perform if @params[:group_by_field] value = @resource @params[:filters].try(:each) do |filter| operator, filter_value = OperatorValueParser.parse(filter[:value]) value = value.where("#{filter[:field]} #{operator} '#{filter_value}'") end value = value.group(@params[:group_by_field]) .send(@params[:aggregate].downcase, @params[:aggregate_field]) .map do |k, v| { key: k, value: v } end @record = Stat.new(value: value) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems