Skip to content

Commit

Permalink
Rewrite deletion unsetting to reuse existing method
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Jun 1, 2024
1 parent 833aeef commit 4d7dec9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/models/user_cleaner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ def set_deletion_date_for_inactive_users
# does not work, this method will prevent active users from being deleted
# as a last resort.
def unset_deletion_date_for_recently_active_users
inactive_users_cached = inactive_users

User.where.not(deletion_date: nil).find_each do |user|
# Note that technically, 40 days is the maximum possible value here,
# if our intended flow works as expected. We use 6 months to be on the
# safe side as we do not want to delete active users.
user.update(deletion_date: nil) if user.last_sign_in_at >= 6.months.ago.to_date
next if inactive_users_cached.include?(user)

user.update(deletion_date: nil)
end
end

Expand Down

0 comments on commit 4d7dec9

Please sign in to comment.