diff --git a/ruby/lib/jam_ruby/lib/email_profile_reminder.rb b/ruby/lib/jam_ruby/lib/email_profile_reminder.rb index 418e8a7a3..ae928da0b 100644 --- a/ruby/lib/jam_ruby/lib/email_profile_reminder.rb +++ b/ruby/lib/jam_ruby/lib/email_profile_reminder.rb @@ -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 diff --git a/web/config/application.rb b/web/config/application.rb index 72e55ba7a..235f72847 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -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" diff --git a/web/config/environments/development.rb b/web/config/environments/development.rb index eb08a6617..5f550f5f5 100644 --- a/web/config/environments/development.rb +++ b/web/config/environments/development.rb @@ -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"