From 6f2cf0e9fd445777999af4e2eae79b9ea32bc907 Mon Sep 17 00:00:00 2001 From: Daniel Uber Date: Tue, 11 Jan 2022 15:33:33 -0600 Subject: [PATCH] Add one day to the new users range (#16065) The download app broadcast (in the Generator) returns early if the user was created less than 7 days ago. It seems counterproductive to filter out _only_ users created in the last 7 days. Add one day to the query range, so users created less than 8 days ago, but more than 7 days ago, receive the final message. --- .../broadcasts/send_welcome_notifications_worker.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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