Created
January 14, 2014 09:01
-
-
Save julesce/8415308 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| PromotionAttemptEvent.count_by_state(mailing.id, stat_type) | |
| when :engaged | |
| PromotionAttemptEvent.count_by_state(mailing.id, stat_type, :unique => true) | |
| when :clicked, :total_clicked, :forward_total_clicked | |
| Clicks.new(mailing, stat_type).count | |
| else | |
| # Stats based on (R)PromotionAttempt models: viewed sent accepted | |
| # opt_out spam bounced hard_bounced soft_bounced other_bounced | |
| State.new(mailing, stat_type).count | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment