Last active
January 4, 2016 21:59
-
-
Save julesce/8684131 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
| mailings_to_refresh = [] | |
| click_thrus_to_delete = [] | |
| promotions_to_refresh = [] | |
| ClickThru.find_each(:select => 'click_thrus.id, mailing_links.mailing_id', | |
| :joins => "INNER JOIN mailing_links ON click_thrus.mailing_link_id = mailing_links.id", | |
| :conditions => {:promotion_attempt_id => 9223372036854775807}) do |click_thru| | |
| click_thrus_to_delete << click_thru.id | |
| mailings_to_refresh << click_thru.mailing_id unless mailings_to_refresh.include?(click_thru.mailing_id) | |
| end | |
| puts "ClickThrus to delete: #{click_thrus_to_delete.inspect}" | |
| click_thrus_to_delete.each do |id| | |
| ClickThru.delete(id) | |
| end | |
| puts "Mailings to refresh: #{mailings_to_refresh.inspect}" | |
| Mailing.find_each(:conditions => {:id => mailings_to_refresh}) do |mailing| | |
| promotions_to_refresh << mailing.promotion_id unless promotions_to_refresh.include?(mailing.promotion_id) | |
| end | |
| puts "Promotions to refresh: #{promotions_to_refresh.inspect}" | |
| Promotion.find_each(:conditions => {:id => promotions_to_refresh}) do |promotion| | |
| promotion.refresh_stats | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment