Skip to content

Commit

Permalink
Avoid sending to enrolled people
Browse files Browse the repository at this point in the history
  • Loading branch information
iHiD committed Dec 16, 2024
1 parent 078d444 commit 7f3c5c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 6 additions & 5 deletions app/models/mailshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def audience_for_bc_viewed(_)
where('user_data.seniority': %i[absolute_beginner beginner]).
includes(user: :bootcamp_data),
lambda do |bootcamp_data|
return if bootcamp_data.enrolled? # Totally redundant, but still
return if bootcamp_data.paid? # Totally redundant, but still

bootcamp_data.user
Expand All @@ -92,7 +93,7 @@ def audience_for_bc_beginners(_)
User::Data.where(seniority: %i[absolute_beginner beginner]).includes(user: :bootcamp_data),
lambda do |user_data|
user = user_data.user
return if user.bootcamp_data&.paid?
return if user.bootcamp_data&.enrolled?

user
end
Expand All @@ -104,7 +105,7 @@ def audience_for_bc_juniors(_)
User::Data.where(seniority: :junior).includes(user: :bootcamp_data),
lambda do |user_data|
user = user_data.user
return if user.bootcamp_data&.paid?
return if user.bootcamp_data&.enrolled?

user
end
Expand All @@ -116,7 +117,7 @@ def audience_for_bc_mid_seniors(_)
User::Data.where(seniority: %i[mid senior]).includes(user: :bootcamp_data),
lambda do |user_data|
user = user_data.user
return if user.bootcamp_data&.paid?
return if user.bootcamp_data&.enrolled?

user
end
Expand All @@ -130,7 +131,7 @@ def audience_for_bc_unspecified_recent_90(_)
lambda do |user_data|
user = user_data.user
return if user.seniority.present?
return if user.bootcamp_data&.paid?
return if user.bootcamp_data&.enrolled?

user
end
Expand All @@ -144,7 +145,7 @@ def audience_for_bc_unspecified(batch)
User.where(id: (start_id..end_id)).includes(:data, :bootcamp_data),
lambda do |user|
return if user.seniority.present?
return if user.bootcamp_data&.paid?
return if user.bootcamp_data&.enrolled?

user
end
Expand Down
2 changes: 0 additions & 2 deletions test/commands/mailshot/send_to_audience_segment_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ class Mailshot::SendToAudienceSegmentTest < ActiveSupport::TestCase
User::Mailshot::Send.expects(:call).with(absolute_beginner_viewed, mailshot)
User::Mailshot::Send.expects(:call).with(beginner, mailshot)
User::Mailshot::Send.expects(:call).with(beginner_viewed, mailshot)
User::Mailshot::Send.expects(:call).with(absolute_beginner_enrolled, mailshot)
User::Mailshot::Send.expects(:call).with(beginner_enrolled, mailshot)

Mailshot::SendToAudienceSegment.(mailshot, :bc_beginners, nil, 20, 0)

Expand Down

0 comments on commit 7f3c5c9

Please sign in to comment.