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.
23 lines
777 B
Ruby
23 lines
777 B
Ruby
module Broadcasts
|
|
class SendWelcomeNotificationsWorker
|
|
include Sidekiq::Worker
|
|
|
|
sidekiq_options queue: :medium_priority, retry: 15
|
|
|
|
def perform
|
|
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
|
|
# 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
|
|
end
|