Class: Workers::RemoveOldUser

Inherits:
Base
  • Object
show all
Defined in:
app/workers/remove_old_user.rb

Instance Method Summary collapse

Instance Method Details

#perform(user_id) ⇒ Object


18
19
20
21
22
23
24
25
26
27
# File 'app/workers/remove_old_user.rb', line 18

def perform(user_id)
  # if user has been flagged as to be removed (see settings.maintenance.remove_old_users)
  # and hasn't logged in since that flag has been set, we remove the user
  if AppConfig.settings.maintenance.remove_old_users.enable?
    user = User.find(user_id)
    if user.remove_after < Time.now and user.last_seen < self.safe_remove_after
      user.close_account!
    end
  end
end

#safe_remove_afterObject


11
12
13
14
15
16
# File 'app/workers/remove_old_user.rb', line 11

def safe_remove_after
  # extra safety time to compare in addition to remove_after
  Time.now-
    (AppConfig.settings.maintenance.remove_old_users.after_days.to_i).days-
    (AppConfig.settings.maintenance.remove_old_users.warn_days.to_i).days
end