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.
This commit is contained in:
Daniel Uber 2022-01-11 15:33:33 -06:00 committed by GitHub
parent fadc84f47e
commit 6f2cf0e9fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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