Skip to content

Commit 92bc485

Browse files
committed
Added more paranoia to the sidekiq worker because some emails are invalid
1 parent e863a7a commit 92bc485

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

app/workers/protip_mailer_popular_protips_worker.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ def perform(from, to)
66
protips = ProtipMailer::Queries.popular_protips(from, to)
77

88
User.find_each(batch_size: 100) do |user|
9-
ProtipMailer.popular_protips(user, protips, from, to).deliver
9+
begin
10+
if REDIS.sismember(ProtipMailer::CAMPAIGN_ID, user.id.to_s)
11+
Rails.logger.warn("Already sent email to #{user.id} please check Redis SET #{ProtipMailer::CAMPAIGN_ID}.")
12+
else
13+
Rails.logger.warn("Sending email to #{user.id}.")
14+
ProtipMailer.popular_protips(user, protips, from, to).deliver
15+
end
16+
rescue => ex
17+
Rails.logger.error("[ProtipMailer.popular_protips] Unable to send email due to '#{ex}' >>\n#{ex.backtrace.join("\n ")}")
18+
Rails.logger.ap([from, to, user, protips], :error)
19+
end
1020
end
1121
end
1222
end

0 commit comments

Comments
 (0)