Skip to content

Instantly share code, notes, and snippets.

View julesce's full-sized avatar

James Thompson julesce

  • Hampshire, United Kingdom
View GitHub Profile
def self.new_count(mailing, stat_type)
case stat_type
when :total
Total.new(mailing, stat_type).count
when :ga
GoogleAnalyticsMailingStat.total_value(mailing)
when :total_viewed
PromotionAttemptEvent.count_by_state(mailing.id, stat_type) + archive_count(mailing, :viewed)
when :tweeted, :facebooked, :plusoned, :pinned, :forwarded, :shared,
:forward_total_viewed, :subscribed
<span style="display:inline-block;font-size:11px;" class="unsubscribe">
<!--[if gte mso 9]>
<v:roundrect href="[[opt_out]]" style="height:20px;v-text-anchor:middle;width:82px;" arcsize="50%" stroke="f" fillcolor="#c5c5cf">
<w:anchorlock/>
<v:textbox inset="0,0,0,0">
<center><a href="[[opt_out]]" style="height: 20px;font-family:Helvetica Neue, Helvetica, Arial, Verdana, sans-serif;font-size:11px;line-height: 170%;font-weight:normal;mso-text-raise:4px;background-color: #c5c5cf; text-align: left; direction: ltr;" title="Unsubscribe"><span style="color: #404055; background-color: #c5c5cf; font-size: 11px;">Unsubscribe</span></a>
</center>
</v:textbox>
</v:roundrect>
def self.paginate(mailing, filter = :delivered, page = 1, per_page = 30)
page = page.to_i
page = 1 if page < 1
per_page = per_page.to_i
per_page = 30 if per_page < 1
total = mailing.count(filter)
continuation_manager = StatsContinuationManager.new(mailing.promotion, mailing,
{ :page => page,
def self.perform(promotion_id)
promotion = Promotion.find(promotion_id)
promotion.mailings_sent.each do |mailing|
migrate_mailing(mailing)
end
promotion.refresh_stats
promotion.store(:stats_migration_end => Time.now)
end
<% @teams.each do |team| %>
<% team.admin_users.each do |user| %>
<tr>
<td><%= team.name %></td>
<td><%= user.name %></td>
<% (1..5).each do |counter| %>
<td><%= link_to(counter, admin_consultant_report_path(user.consultant_reports.select {|x| x.week.to_i == counter})) %></td>
<% end %>
</tr>
<% end %>