Class: Campaign

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
E9::ActiveRecord::AttributeSearchable, E9Rails::ActiveRecord::STI
Defined in:
app/models/campaign.rb

Overview

The base campaign class

A Campaign is created with a unique code, which in turn generates PageViews, which maybe become Leads (Offers), which may result in Deals.

Defined Under Namespace

Classes: Drop

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultObject



108
109
110
# File 'app/models/campaign.rb', line 108

def self.default
  NoCampaign.first || NoCampaign.create
end

Instance Method Details

#costObject

The sum cost of this campaign (Must be implemented by subclasses)

Raises:

  • (NotImplementedError)


137
138
139
# File 'app/models/campaign.rb', line 137

def cost
  raise NotImplementedError
end

#new_visit_countObject



117
118
119
# File 'app/models/campaign.rb', line 117

def new_visit_count
  new_visits.group(:session).count.keys.length
end

#new_visit_page_view_countObject



121
122
123
# File 'app/models/campaign.rb', line 121

def new_visit_page_view_count
  new_visits.group(:session).count.values.sum
end

#repeat_visit_countObject



125
126
127
# File 'app/models/campaign.rb', line 125

def repeat_visit_count
  repeat_visits.group(:session).count.keys.length
end

#repeat_visit_page_view_countObject



129
130
131
# File 'app/models/campaign.rb', line 129

def repeat_visit_page_view_count
  repeat_visits.group(:session).count.values.sum
end

#to_liquidObject



145
146
147
# File 'app/models/campaign.rb', line 145

def to_liquid
  Drop.new(self)
end

#to_sObject



141
142
143
# File 'app/models/campaign.rb', line 141

def to_s
  name.dup.tap {|n| n << " (#{code})" if code.present? }
end