Sha256: 6aed99a0055d6d11c6fa719643d3f1fcc44f7aeeb233458ad4dc2a16e4f6cd47

Contents?: true

Size: 801 Bytes

Versions: 25

Compression:

Stored size: 801 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 = OperatorValueParser.add_where(value, 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 = Model::Stat.new(value: value)
      end
    end

  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
forest_liana-1.3.6 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.3.5 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.3.4 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.3.3 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.3.2 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.3.1 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.3.0 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.2.6 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.2.5 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.2.3 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.2.2 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.2.1 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.1.35 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.1.34 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.1.33 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.1.32 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.1.31 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.1.30 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.1.29 app/services/forest_liana/pie_stat_getter.rb
forest_liana-1.1.28 app/services/forest_liana/pie_stat_getter.rb