def calculate_selects
      return @selects if defined?(@selects)

      functions = ['minimum', 'maximum', 'average', 'sum', 'count']
      @selects = []
      @selects << params[:group_by] if params[:group_by]
      Array(params[:select]).each do |select|
        select.each do |func, column|
          if (parts = column.split(".")).length > 1
            @model = parts[0].singularize.camelize.constantize
            column = parts[1]
          end
          
          column = column == '*' ? Arel.star : column.to_sym
          if functions.include?(func.to_s.downcase)
            @selects << ((@model || model).arel_table[column].send(func))
          end
        end
      end

      @selects
    end
def calculate_selects
      return @selects if defined?(@selects)

      functions = ['minimum', 'maximum', 'average', 'sum', 'count']
      @selects = []
      @selects << params[:group_by] if params[:group_by]
      Array(params[:select]).each do |select|
        select.each do |func, column|
          if (parts = column.split(".")).length > 1
            @model = parts[0].singularize.camelize.constantize
            column = parts[1]
          end
          
          column = column == '*' ? Arel.star : column.to_sym
          if functions.include?(func.to_s.downcase)
            @selects << ((@model || model).arel_table[column].send(func))
          end
        end
      end

      @selects
    end
Used in #calculate
 [{ count: :id }]
 [{ count: '*' }]
 [{ count: '*', maximum: :id, minimum: :id }]
 [{ count: '*' }, { maximum: :id }, { minimum: :id }]
 TODO: Sanitize (normalize_select_params(params[:select], model))