Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/jobs/user_session/clear_old_user_sessions_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class UserSession
class ClearOldUserSessionsJob < ApplicationJob
queue_as :low

def perform
UserSession.expired.where("created_at < ?", 1.year.ago).find_each(&:clear_metadata!)
end

end

end
8 changes: 8 additions & 0 deletions app/models/user_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ def expired?
expiration_at <= Time.now
end

def clear_metadata!
update!(
device_info: nil,
latitude: nil,
longitude: nil,
)
end

private

def user_is_unlocked
Expand Down
5 changes: 5 additions & 0 deletions config/schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ update_teenager_column_job:
cron: "0 7 * * *" # run every 1 day
class: "User::UpdateTeenagerColumnJob"

clear_old_user_sessions:
cron: "0 3 * * *" # every day at 3:00 AM
class: "UserSession::ClearOldUserSessionsJob"
queue: low

card_grant_expiration_job:
cron: "0 7 * * *" # run every 1 day
class: "CardGrant::ExpirationJob"
Expand Down
Loading