Simplify and label date calculation (#16052)
* Name the created after timestamp and remove temporary variables The logic used to calculate the live at time, the week ago time, then compare them to find the more recent value. Move all of this logic to a method (there's a guard to exit if the setting is nil, so this should be safe). * Mark method private This is not part of the public api (for workers, this should be `#perform` alone). Mark it private
This commit is contained in:
parent
7dc59eb4bf
commit
1db02f355c
1 changed files with 6 additions and 4 deletions
|
|
@ -10,12 +10,14 @@ module Broadcasts
|
|||
# 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
|
||||
|
||||
notifications_live_at = Settings::General.welcome_notifications_live_at
|
||||
week_ago = 7.days.ago
|
||||
latest_date = notifications_live_at > week_ago ? notifications_live_at : week_ago
|
||||
User.select(:id).where("created_at > ?", latest_date).find_each do |user|
|
||||
User.select(:id).where("created_at > ?", created_after).find_each do |user|
|
||||
Broadcasts::WelcomeNotification::Generator.call(user.id)
|
||||
end
|
||||
end
|
||||
|
||||
def created_after
|
||||
[Settings::General.welcome_notifications_live_at, 7.days.ago].max
|
||||
end
|
||||
private :created_after
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue