app/models/page_view.rb in e9_crm-0.1.26 vs app/models/page_view.rb in e9_crm-0.1.27

- old
+ new

@@ -19,32 +19,15 @@ belongs_to :tracking_cookie belongs_to :campaign, :inverse_of => :page_views has_one :user, :through => :tracking_cookie - #attr_accessor :should_cache - - #after_create :increment_campaign_visit_cache, :if => '!!should_cache' - - scope :by_user, lambda {|*users| - users.flatten! - users.map! &:to_param - joins(:tracking_cookie).where(TrackingCookie.arel_table[:user_id].send *(users.length == 1 ? [:eq, users.pop] : [:in, users])) + scope :by_users, lambda {|*users| + joins(:tracking_cookie) & TrackingCookie.for_users(users) } - scope :by_campaign, lambda {|*campaigns| - campaigns.flatten! - campaigns.map! &:to_param - where(arel_table[:campaign_id].send *(campaigns.length == 1 ? [:eq, campaigns.pop] : [:in, campaigns])) - } - scope :new_visits, lambda {|v=true| where(:new_visit => v) } scope :repeat_visits, lambda { new_visits(false) } delegate :name, :code, :to => :campaign, :prefix => true, :allow_nil => true - - protected - - #def increment_campaign_visit_cache - #Campaign.increment_counter(new_visit ? :new_visits : :repeat_visits, campaign_id) - #end + delegate :contact, :to => :user, :allow_nil => true end