lib/gooddata/models/metadata/attribute.rb
# Creates the basic count metric with the attribute used. If you need to compute the attribute on a different dataset you can specify that in params. The metric created is not saved.
# @param [Hash] options the options to pass to the value list
# @option options [Symbol] :type type of aggregation function.
# @option options [Symbol] :attribute Use this attribute if you need to express different dataset for performing the computation on. It basically serves for creating metrics like SELECT COUNT(User, Opportunity).
# @return [GoodData::Metric]
Creates the basic count metric with the attribute used. If you need to compute the attribute on a different dataset you can specify that in params. The metric created is not saved.
Creates the basic count metric with the attribute used . If you need to compute the attribute on a different dataset you can specify that in params . The metric created is not saved .
def create_metric(options = {})
      an_attribute = options[:attribute]
      a_type = options[:type] || :count
      fail "Suggested aggreagtion function (#{a_type}) does not exist for base metric created out of attribute. You can use only one of #{ATTRIBUTE_BASE_AGGREGATIONS.map { |x| ':' + x.to_s }.join(',')}" unless ATTRIBUTE_BASE_AGGREGATIONS.include?(a_type)
      a_title = options[:title] || "#{a_type} of #{title}"
      if an_attribute
        project.create_metric("SELECT #{a_type.to_s.upcase}([#{uri}], [#{an_attribute.uri}])", title: a_title, extended_notation: false)
      else
        project.create_metric("SELECT #{a_type.to_s.upcase}([#{uri}])", title: a_title, extended_notation: false)
      end
    end
def create_metric ( options = { } ) an_attribute = options [ :attribute ] a_type = options [ :type ] || :count fail "Suggested aggreagtion function (#{a_type}) does not exist for base metric created out of attribute. You can use only one of #{ATTRIBUTE_BASE_AGGREGATIONS.map { |x| ':' + x.to_s }.join(',')}" unless ATTRIBUTE_BASE_AGGREGATIONS . include? ( a_type ) a_title = options [ :title ] || "#{a_type} of #{title}" if an_attribute project . create_metric ( "SELECT #{a_type.to_s.upcase}([#{uri}], [#{an_attribute.uri}])" , title : a_title , extended_notation : false ) else project . create_metric ( "SELECT #{a_type.to_s.upcase}([#{uri}])" , title : a_title , extended_notation : false ) end end
Creates the basic count metric with the attribute used.
Creates the basic count metric with the attribute used .
None
GoodData::Metric
options
:attribute Use this attribute if you need to express different dataset for performing the computation on. It basically serves for creating metrics like SELECT COUNT(User, Opportunity).
: attribute Use this attribute if you need to express different dataset for performing the computation on . It basically serves for creating metrics like SELECT COUNT ( User Opportunity ) .
options the options to pass to the value list
options the options to pass to the value list