trail end reminderd

send emails when the trail perieod expired.
This commit is contained in:
Nuwan 2025-08-19 00:07:09 +05:30
parent a84a55f178
commit 7e2c917ca0
9 changed files with 205 additions and 8 deletions

View File

@ -7,9 +7,9 @@
execute "ALTER TABLE users ADD COLUMN profile_complete_reminder2_sent_at TIMESTAMP"
execute "ALTER TABLE users ADD COLUMN profile_complete_reminder3_sent_at TIMESTAMP"
User.find_each(batch_size:100) do |user|
User.where(id:user.id).update_all(profile_completed_at: Time.now)
end
# User.find_each(batch_size:100) do |user|
# User.where(id:user.id).update_all(profile_completed_at: Time.now)
# end
#User.where('users.id IN (SELECT player_id FROM musicians_instruments) OR users.id IN (SELECT player_id FROM genre_players)').update_all(profile_completed_at: Time.now)
end
def self.down

View File

@ -1,9 +1,9 @@
class AddSignupSurveySentAtToUsers < ActiveRecord::Migration
def self.up
execute "ALTER TABLE users ADD COLUMN signup_survey_sent_at TIMESTAMP"
User.find_each(batch_size:100) do |user|
User.where(id:user.id).update_all(signup_survey_sent_at: Time.now)
end
# User.find_each(batch_size:100) do |user|
# User.where(id:user.id).update_all(signup_survey_sent_at: Time.now)
# end
end
def self.down
execute "ALTER TABLE users DROP COLUMN signup_survey_sent_at"

View File

@ -125,6 +125,7 @@ require "jam_ruby/lib/email_signup_survey"
require "jam_ruby/lib/gear_setup_reminder"
require "jam_ruby/lib/test_gear_reminder"
require "jam_ruby/lib/group_session_reminder"
require "jam_ruby/lib/trial_expires_reminder"
require "jam_ruby/amqp/amqp_connection_manager"
require "jam_ruby/database"
require "jam_ruby/message_factory"

View File

@ -528,6 +528,30 @@ module JamRuby
end
end
def trial_expires_reminder1(user)
@user = user
mail(:to => user.email, :subject => I18n.t('user_mailer.trial_expires_reminder1.subject')) do |format|
format.text
format.html { render layout: "user_mailer_beta" }
end
end
def trial_expires_reminder2(user)
@user = user
mail(:to => user.email, :subject => I18n.t('user_mailer.trial_expires_reminder2.subject')) do |format|
format.text
format.html { render layout: "user_mailer_beta" }
end
end
def trial_expires_reminder3(user)
@user = user
mail(:to => user.email, :subject => I18n.t('user_mailer.trial_expires_reminder3.subject')) do |format|
format.text
format.html { render layout: "user_mailer_beta" }
end
end
def signup_survey(user)
@user = user
@subject = I18n.t('user_mailer.signup_survey.subject')

View File

@ -18,6 +18,7 @@ module JamRuby
GearSetupReminder.send_reminders
TestGearReminder.send_reminders
GroupSessionReminder.send_reminders
TrialExpiresReminder.send_reminders
ConnectionManager.new.cleanup_dangling
@@log.info("done")

View File

@ -322,4 +322,115 @@ describe UserMailer do
end
end
describe "sends trial expires reminder 1", focus: true do
let(:mail) { ActionMailer::Base.deliveries.last }
before(:each) do
ActionMailer::Base.deliveries.clear
UserMailer.trial_expires_reminder1(user).deliver_now
end
it "sends exactly one email" do
expect(ActionMailer::Base.deliveries.length).to eq(1)
end
it "has the correct from address" do
mail['from'].to_s.should == UserMailer::DEFAULT_SENDER
end
it "has the correct recipient" do
expect(mail.to).to eq([user.email])
end
it "is multipart" do
expect(mail).to be_multipart
end
it "has the expected subject" do
expect(mail.subject).to include("Your free gold trial has expired, but you have great options to keep playing!")
end
it "includes the correct content in the HTML part" do
expect(mail.html_part.body.to_s).to include("We hope youve enjoyed your 30-day free gold trial with JamKazam")
end
it "includes the correct content in the text part" do
expect(mail.text_part.body.to_s).to include("We hope youve enjoyed your 30-day free gold trial with JamKazam")
end
end
describe "sends trial expires reminder 2", focus: true do
let(:mail) { ActionMailer::Base.deliveries.last }
before(:each) do
ActionMailer::Base.deliveries.clear
UserMailer.trial_expires_reminder2(user).deliver_now
end
it "sends exactly one email" do
expect(ActionMailer::Base.deliveries.length).to eq(1)
end
it "has the correct from address" do
mail['from'].to_s.should == UserMailer::DEFAULT_SENDER
end
it "has the correct recipient" do
expect(mail.to).to eq([user.email])
end
it "is multipart" do
expect(mail).to be_multipart
end
it "has the expected subject" do
expect(mail.subject).to include("Dont forget to check your options to keep playing")
end
it "includes the correct content in the HTML part" do
expect(mail.html_part.body.to_s).to include("Your 30-day free gold trial with JamKazam has expired")
end
it "includes the correct content in the text part" do
expect(mail.text_part.body.to_s).to include("Your 30-day free gold trial with JamKazam has expired")
end
end
describe "sends trial expires reminder 3", focus: true do
let(:mail) { ActionMailer::Base.deliveries.last }
before(:each) do
ActionMailer::Base.deliveries.clear
UserMailer.trial_expires_reminder3(user).deliver_now
end
it "sends exactly one email" do
expect(ActionMailer::Base.deliveries.length).to eq(1)
end
it "has the correct from address" do
mail['from'].to_s.should == UserMailer::DEFAULT_SENDER
end
it "has the correct recipient" do
expect(mail.to).to eq([user.email])
end
it "is multipart" do
expect(mail).to be_multipart
end
it "has the expected subject" do
expect(mail.subject).to include("One last reminder!")
end
it "includes the correct content in the HTML part" do
expect(mail.html_part.body.to_s).to include("Your 30-day free gold trial with JamKazam has expired")
end
it "includes the correct content in the text part" do
expect(mail.text_part.body.to_s).to include("Your 30-day free gold trial with JamKazam has expired")
end
end
end

View File

@ -526,6 +526,7 @@ if defined?(Bundler)
config.gear_setup_reminders_effective_from_date = "2025-06-10"
config.test_gear_reminders_effective_from_date = "2025-07-24"
config.group_session_reminders_effective_from_date = "2025-08-12"
config.trial_expires_reminders_effective_from_date = "2025-08-17"
config.action_mailer.asset_host = config.action_controller.asset_host
end

View File

@ -131,4 +131,5 @@ SampleApp::Application.configure do
config.gear_setup_reminders_effective_from_date = "2025-06-10"
config.test_gear_reminders_effective_from_date = "2025-07-24"
config.group_session_reminders_effective_from_date = "2025-08-12"
config.trial_expires_reminders_effective_from_date = "2025-08-17"
end

View File

@ -248,6 +248,64 @@ en:
regards: "Best Regards,"
signature: "JamKazam Team"
trial_expires_reminder1:
subject: "Your free gold trial has expired, but you have great options to keep playing!"
greeting: "Hello"
paragraph1: |
We hope youve enjoyed your 30-day free gold trial with JamKazam. If youve used it to play music in online sessions with others, below is a summary of your options to keep playing. If you havent finished setting up your gear or havent played in sessions with others yet, please send us an email at <a href="mailto:support@jamkazam.com">support@jamkazam.com</a> to let us know where youre stuck. We have a team that would love to help you!<br />
<ul>
<li>
<strong>Free Plan </strong> You can keep playing free on JamKazam with your current account. Our free plan lets you play 4 hours per month.
</li>
<li>
<strong>Premium Plans </strong> You can also subscribe to our silver, gold, or platinum plans, starting at $4.99/month, with upgrades to unlimited play time, higher audio quality, HD video, and access to premium features like audio and video recording, session broadcasting, and much more. <a href="https://jamkazam.freshdesk.com/support/solutions/articles/66000122535">Read our help article on plans</a> to get all the details and see whats right for you.
</li>
</ul><br />
paragraph2: |
If youd like to take advantage of one of our premium plans, <a href="https://jamkazam.freshdesk.com/support/solutions/articles/66000529807">check this help article</a> that explains how to set up a payment method. Then <a href="https://jamkazam.freshdesk.com/support/solutions/articles/66000529117">review this help article</a> that explains how to select your premium plan.
regards: "Best Regards,"
signature: "JamKazam Team"
trial_expires_reminder2:
subject: "Dont forget to check your options to keep playing"
greeting: "Hello"
paragraph1: |
Your 30-day free gold trial with JamKazam has expired, but you have great options to continue playing music online. <br />
<ul>
<li>
<strong>Free Plan </strong> You can keep playing free on JamKazam with your current account. Our free plan lets you play 4 hours per month.
</li>
<li>
<strong>Premium Plans </strong> You can also subscribe to our silver, gold, or platinum plans, starting at $4.99/month, with upgrades to unlimited play time, higher audio quality, HD video, and access to premium features like audio and video recording, session broadcasting, and much more. <a href="https://jamkazam.freshdesk.com/support/solutions/articles/66000122535">Read our help article on plans</a> to get all the details and see whats right for you.
</li>
</ul><br />
paragraph2: |
If youd like to take advantage of one of our premium plans, <a href="https://jamkazam.freshdesk.com/support/solutions/articles/66000529807">check this help article</a> that explains how to set up a payment method. Then <a href="https://jamkazam.freshdesk.com/support/solutions/articles/66000529117">review this help article</a> that explains how to select your premium plan.
paragraph3: |
If you havent finished setting up your gear or havent played in sessions with others yet, please send us an email at <a href="mailto:support@jamkazam.com">support@jamkazam.com</a> to let us know where youre stuck. We have a team that would love to help you!
regards: "Best Regards,"
signature: "JamKazam Team"
trial_expires_reminder3:
subject: "One last reminder!"
greeting: "Hello"
paragraph1: |
Your 30-day free gold trial with JamKazam has expired, but you have great options to continue playing music online.
<ul>
<li>
<strong>Free Plan </strong> You can keep playing free on JamKazam with your current account. Our free plan lets you play 4 hours per month.
</li>
<li>
<strong>Premium Plans </strong> You can also subscribe to our silver, gold, or platinum plans, starting at $4.99/month, with upgrades to unlimited play time, higher audio quality, HD video, and access to premium features like audio and video recording, session broadcasting, and much more. <a href="https://jamkazam.freshdesk.com/support/solutions/articles/66000122535">Read our help article on plans</a> to get all the details and see whats right for you.
</li>
</ul>
paragraph2: |
If youd like to take advantage of one of our premium plans, <a href="https://jamkazam.freshdesk.com/support/solutions/articles/66000529807">check this help article</a> that explains how to set up a payment method. Then <a href="https://jamkazam.freshdesk.com/support/solutions/articles/66000529117">review this help article</a> that explains how to select your premium plan.
paragraph3: |
If you havent finished setting up your gear or havent played in sessions with others yet, please send us an email at support@jamkazam.com to let us know where youre stuck. We have a team that would love to help you!
regards: "Best Regards,"
signature: "JamKazam Team"
signup_survey:
subject: "Let us help you to be successful on JamKazam"
greeting: "Hi"