Sha256: a059a3095bfc1fec7d7c5682d0fc642374cc93a76deffc8c5fc40c5a68404ac8
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
module Impressionist module Impressionable def is_impressionable has_many :impressions, :as=>:impressionable include InstanceMethods end module InstanceMethods def impressionable? true end def impression_count(start_date=nil,end_date=Time.now) start_date.blank? ? impressions.all.size : impressions.where("created_at>=? and created_at<=?",start_date,end_date).all.size end def unique_impression_count(start_date=nil,end_date=Time.now) start_date.blank? ? impressions.group(:request_hash).all.size : impressions.where("created_at>=? and created_at<=?",start_date,end_date).group(:request_hash).all.size end def unique_impression_count_ip(start_date=nil,end_date=Time.now) start_date.blank? ? impressions.group(:ip_address).all.size : impressions.where("created_at>=? and created_at<=?",start_date,end_date).group(:ip_address).all.size end def unique_impression_count_session(start_date=nil,end_date=Time.now) start_date.blank? ? impressions.group(:session_hash).all.size : impressions.where("created_at>=? and created_at<=?",start_date,end_date).group(:session_hash).all.size end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
impressionist-0.3.2 | app/models/impressionist/impressionable.rb |
impressionist-0.3.1 | app/models/impressionist/impressionable.rb |