Sha256: a6e2ee2e5955f4532bcce0de4ca0817b523051b9dc0050aef2a66e36a5eb5038
Contents?: true
Size: 787 Bytes
Versions: 10
Compression:
Stored size: 787 Bytes
Contents
require 'active_reporter/dimension/base' module ActiveReporter module Dimension class Category < Base def filter(relation) values = filter_values query = "#{expression} IN (?)" query = "#{expression} IS NULL OR #{query}" if values.include?(nil) relation.where(query, values.compact) end def group(relation) order relation.select("#{expression} AS #{sql_value_name}").group(sql_value_name) end def group_values return filter_values if filtering? i = report.groupers.index(self) report.raw_data.keys.map { |x| x[i] }.uniq end def all_values relate(report.base_relation).pluck("DISTINCT #{expression}").map(&method(:sanitize_sql_value)) end end end end
Version data entries
10 entries across 10 versions & 1 rubygems