diff --git a/app/workers/broadcasts/send_welcome_notifications_worker.rb b/app/workers/broadcasts/send_welcome_notifications_worker.rb index 91fca4192..b1855a6ed 100644 --- a/app/workers/broadcasts/send_welcome_notifications_worker.rb +++ b/app/workers/broadcasts/send_welcome_notifications_worker.rb @@ -5,18 +5,18 @@ module Broadcasts sidekiq_options queue: :medium_priority, retry: 15 def perform - # In order to prevent new users from receiving multiple welcome notifications in a day, - # a feature_live_date is required. The script will only be effective after feature_live_date - # and will ultimately be superseded by 7.days.ago when it's larger than feature_live_date. return unless Settings::General.welcome_notifications_live_at User.select(:id).where("created_at > ?", created_after).find_each do |user| + # the Generator ensures only one notification is created per user per day Broadcasts::WelcomeNotification::Generator.call(user.id) end end def created_after - [Settings::General.welcome_notifications_live_at, 7.days.ago].max + # The script will only be effective after feature_live_date + # and will ultimately be superseded by 8.days.ago when it's larger than feature_live_date. + [Settings::General.welcome_notifications_live_at, 8.days.ago].max end private :created_after end