FIX: don't send activation reminder to staged users

FIX: don’t send activation reminder to staged users

diff --git a/app/jobs/scheduled/activation_reminder_emails.rb b/app/jobs/scheduled/activation_reminder_emails.rb
index 8b55100..b9f6c2e 100644
--- a/app/jobs/scheduled/activation_reminder_emails.rb
+++ b/app/jobs/scheduled/activation_reminder_emails.rb
@@ -4,8 +4,8 @@ module Jobs
 
     def execute(args)
       User.joins("LEFT JOIN user_custom_fields ON users.id = user_id AND user_custom_fields.name = 'activation_reminder'")
-        .where(active: false, user_custom_fields: { value: nil })
-        .where('users.created_at < ?', 2.days.ago)
+        .where(active: false, staged: false, user_custom_fields: { value: nil })
+        .where('users.created_at BETWEEN ? AND ?', 3.days.ago, 2.days.ago)
         .find_each do |user|
 
         user.custom_fields['activation_reminder'] = true

GitHub sha: ab790604

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there:

Is a bit confusing, I guess it magically left joins?

1 Like

I agree. @nbianca can you unconfuse this?

1 Like

What is confusing about this?

That line is equivalent to WHERE user_custom_fields.value IS NULL. The join happens before: User.joins("LEFT JOIN user_custom_fields ON users.id = user_id AND user_custom_fields.name = 'activation_reminder'").

2 Likes

I see, oops :blush: sorry

1 Like