# frozen_string_literal: true class Segment include Virtus.model GROUP_BY_FIELDS = %w( advertiser_id advertisement_id campaign_id channel_id app_id exchange_id publisher_id agency_id site_id third_party_id supply_id ).freeze COMPOUND_METRICS_FIELDS = Config.compound_metric_types.reject { |m| m.include?('render') }.map(&:pluralize) AGGREGATED_METRIC_FIELDS = Config.aggregated_metric_types.map(&:pluralize) COST_METRIC_FIELDS = Config.cost_metrics VERIFIED_FIELDS = (GROUP_BY_FIELDS + AGGREGATED_METRIC_FIELDS + COMPOUND_METRICS_FIELDS + COST_METRIC_FIELDS).sort.freeze attribute :shard, Integer attribute :siblings, Array[String] GROUP_BY_FIELDS.each do |f| attribute f.to_sym, String end AGGREGATED_METRIC_FIELDS.each do |f| attribute f.to_sym, Integer end COMPOUND_METRICS_FIELDS.each do |f| attribute f.to_sym, Integer end COST_METRIC_FIELDS.each do |f| attribute f.to_sym, Float end def hash Hashtastic::DictionaryValuesHasher.call(attributes, VERIFIED_FIELDS) end end