ensure not to send email 2 and 3 tighltly behind email 1 in this sequence

This commit is contained in:
Nuwan 2025-09-30 13:14:39 +05:30
parent 675bf2b69c
commit fe6157e8cf
3 changed files with 9 additions and 6 deletions

View File

@ -4,6 +4,7 @@ module JamRuby
def self.send_reminders
begin
cutoff_date = Date.parse(Rails.application.config.profile_complete_reminders_effective_from_date) # Define a cutoff date for the profile completion emails
#If the user has not updated their profile 1 day after signup, then send reminder email1
reminder1_users.find_each do |user|
UserMailer.profile_complete_reminder1(user).deliver_now
@ -31,16 +32,16 @@ module JamRuby
User.where("users.profile_completed_at IS NULL AND users.subscribe_email = ?", true)
end
def self.reminder1_users
EmailProfileReminder.prospect_users.where("users.created_at::date = ? AND users.profile_complete_reminder1_sent_at IS NULL", 1.day.ago.to_date)
def self.reminder1_users(cutoff_date)
EmailProfileReminder.prospect_users.where("users.created_at > ? AND users.created_at::date <= ? AND users.profile_complete_reminder1_sent_at IS NULL", cutoff_date, 1.day.ago.to_date)
end
def self.reminder2_users
EmailProfileReminder.prospect_users.where("users.created_at::date = ? AND users.profile_complete_reminder1_sent_at IS NOT NULL AND users.profile_complete_reminder2_sent_at IS NULL", 3.days.ago.to_date)
def self.reminder2_users(cutoff_date)
EmailProfileReminder.prospect_users.where("users.created_at > ? AND GREATEST(users.created_at::date, users.profile_complete_reminder1_sent_at::date) <= ? AND users.profile_complete_reminder1_sent_at IS NOT NULL AND users.profile_complete_reminder2_sent_at IS NULL", cutoff_date, 3.days.ago.to_date)
end
def self.reminder3_users
EmailProfileReminder.prospect_users.where("users.created_at::date = ? AND users.profile_complete_reminder2_sent_at IS NOT NULL AND users.profile_complete_reminder3_sent_at IS NULL", 5.days.ago.to_date)
def self.reminder3_users(cutoff_date)
EmailProfileReminder.prospect_users.where("users.created_at > ? AND GREATEST(users.created_at::date, users.profile_complete_reminder2_sent_at::date) <= ? AND users.profile_complete_reminder2_sent_at IS NOT NULL AND users.profile_complete_reminder3_sent_at IS NULL", cutoff_date, 5.days.ago.to_date)
end

View File

@ -523,6 +523,7 @@ if defined?(Bundler)
config.signup_survey_url = "https://www.surveymonkey.com/r/WVBKLYL"
config.signup_survey_cutoff_date = "2025-06-10"
config.profile_complete_reminders_effective_from_date = "2025-06-10"
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"

View File

@ -128,6 +128,7 @@ SampleApp::Application.configure do
config.send_user_match_mail_only_to_jamkazam_team = false
config.signup_survey_url = "https://www.surveymonkey.com/r/WVBKLYL"
config.signup_survey_cutoff_date = "2025-06-10"
config.profile_complete_reminders_effective_from_date = "2025-06-10"
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"