From e863a7a6305f71749ddc2140a92d621226c432b0 Mon Sep 17 00:00:00 2001 From: Mike Hall Date: Wed, 3 Sep 2014 21:52:19 -0500 Subject: [PATCH 1/2] Removed the subject prefix from popular protips --- app/mailers/protip_mailer.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/mailers/protip_mailer.rb b/app/mailers/protip_mailer.rb index a10bf4a3..b6abf4fb 100644 --- a/app/mailers/protip_mailer.rb +++ b/app/mailers/protip_mailer.rb @@ -16,7 +16,6 @@ class ProtipMailer < ActionMailer::Base endorsements: 'endorsements', protips_count: 'protips' } - ACTIVITY_SUBJECT_PREFIX = '[Coderwall]' CAMPAIGN_ID = 'protip_mailer-popular_protips' ################################################################################# From 92bc485cb03438a0a99d3b82585b7776ebd65b40 Mon Sep 17 00:00:00 2001 From: Mike Hall Date: Thu, 4 Sep 2014 07:21:38 -0500 Subject: [PATCH 2/2] Added more paranoia to the sidekiq worker because some emails are invalid --- app/workers/protip_mailer_popular_protips_worker.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/workers/protip_mailer_popular_protips_worker.rb b/app/workers/protip_mailer_popular_protips_worker.rb index cf9e520d..1795acf2 100644 --- a/app/workers/protip_mailer_popular_protips_worker.rb +++ b/app/workers/protip_mailer_popular_protips_worker.rb @@ -6,7 +6,17 @@ def perform(from, to) protips = ProtipMailer::Queries.popular_protips(from, to) User.find_each(batch_size: 100) do |user| - ProtipMailer.popular_protips(user, protips, from, to).deliver + begin + if REDIS.sismember(ProtipMailer::CAMPAIGN_ID, user.id.to_s) + Rails.logger.warn("Already sent email to #{user.id} please check Redis SET #{ProtipMailer::CAMPAIGN_ID}.") + else + Rails.logger.warn("Sending email to #{user.id}.") + ProtipMailer.popular_protips(user, protips, from, to).deliver + end + rescue => ex + Rails.logger.error("[ProtipMailer.popular_protips] Unable to send email due to '#{ex}' >>\n#{ex.backtrace.join("\n ")}") + Rails.logger.ap([from, to, user, protips], :error) + end end end end