# frozen_string_literal: true module Voucher class Segment include Virtus.model COMPOUND_METRICS = %w( bot_clicks bot_decision_win_clicks bot_decision_win_impressions bot_impressions bot_loaded_clicks bot_loaded_impressions decision_win_clicks decision_win_impressions loaded_clicks loaded_impressions non_bot_clicks non_bot_decision_win_clicks non_bot_decision_win_impressions non_bot_impressions non_bot_loaded_clicks non_bot_loaded_impressions non_viewable_bot_decision_win_clicks non_viewable_bot_decision_win_impressions non_viewable_bot_loaded_clicks non_viewable_bot_loaded_impressions non_viewable_clicks non_viewable_decision_win_clicks non_viewable_decision_win_impressions non_viewable_impressions non_viewable_loaded_clicks non_viewable_loaded_impressions non_viewable_non_bot_clicks non_viewable_non_bot_decision_win_clicks non_viewable_non_bot_decision_win_impressions non_viewable_non_bot_impressions non_viewable_non_bot_loaded_clicks non_viewable_non_bot_loaded_impressions viewable_bot_clicks viewable_bot_decision_win_clicks viewable_bot_decision_win_impressions viewable_bot_impressions viewable_bot_loaded_clicks viewable_bot_loaded_impressions viewable_clicks viewable_decision_win_clicks viewable_decision_win_impressions viewable_impressions viewable_loaded_clicks viewable_loaded_impressions viewable_non_bot_clicks viewable_non_bot_decision_win_clicks viewable_non_bot_decision_win_impressions viewable_non_bot_impressions viewable_non_bot_loaded_clicks viewable_non_bot_loaded_impressions ).freeze FIELDS = %w( advertiser_id agency_id app_id campaign_id channel_id clicks conversions decision_cost exchange_id impressions publisher_id site_id supply_id third_party_id win_cost ).sort.freeze + COMPOUND_METRICS attribute :advertiser_id, String attribute :agency_id, String attribute :app_id, String attribute :campaign_id, String attribute :channel_id, String attribute :clicks, Integer attribute :conversions, Integer attribute :decision_cost, Integer attribute :exchange_id, String attribute :impressions, Integer attribute :publisher_id, String attribute :site_id, String attribute :supply_id, String attribute :third_party_id, String attribute :win_cost, Integer attribute :shard, Integer attribute :siblings, Array[String] COMPOUND_METRICS.each do |metric| attribute metric.to_sym, Integer end def hash Hashtastic::DictionaryValuesHasher.call(attributes, FIELDS) end end end