def impressionist_count(options={})
      # Uses these options as defaults unless overridden in options hash
      options.reverse_merge!(:filter => :request_hash, :start_date => nil, :end_date => Time.now)

      # If a start_date is provided, finds impressions between then and the end_date. Otherwise returns all impressions
      imps = options[:start_date].blank? ? impressions : impressions.where("created_at >= ? and created_at <= ?", options[:start_date], options[:end_date])

      if options[:message]
        imps = imps.where("impressions.message = ?", options[:message])
      end

      # Count all distinct impressions unless the :all filter is provided.
      distinct = options[:filter] != :all
      if Rails::VERSION::MAJOR >= 4
        distinct ? imps.select(options[:filter]).distinct.count : imps.count
      else
        distinct ? imps.count(options[:filter], :distinct => true) : imps.count
      end
    end
def impressionist_count(options={})
      # Uses these options as defaults unless overridden in options hash
      options.reverse_merge!(:filter => :request_hash, :start_date => nil, :end_date => Time.now)

      # If a start_date is provided, finds impressions between then and the end_date. Otherwise returns all impressions
      imps = options[:start_date].blank? ? impressions : impressions.where("created_at >= ? and created_at <= ?", options[:start_date], options[:end_date])

      if options[:message]
        imps = imps.where("impressions.message = ?", options[:message])
      end

      # Count all distinct impressions unless the :all filter is provided.
      distinct = options[:filter] != :all
      if Rails::VERSION::MAJOR >= 4
        distinct ? imps.select(options[:filter]).distinct.count : imps.count
      else
        distinct ? imps.count(options[:filter], :distinct => true) : imps.count
      end
    end
end of ClassMethods