Skip to content

Commit

Permalink
fix background job for token deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 11, 2021
1 parent c0f157f commit 6e64e20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/jobs/user_token_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class UserTokenJob < ApplicationJob

def perform(user)
ActiveRecord::Base.connection_pool.with_connection do
user.update(orcid_expires_at: "1970-01-01", orcid_token: nil),
user.update(orcid_expires_at: "1970-01-01", orcid_token: nil)
end
end
end
6 changes: 3 additions & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ def self.delete_expired_token(index: nil)
response = User.query(query, index: index, page: { size: 1000, cursor: cursor })
break if response.results.results.empty?

Rails.logger.info "Deleting #{response.results.length} User ORCID tokens starting with _id #{response.results.to_a.first[:_id]}."
Rails.logger.info "Deleting #{response.results.to_a.length} User ORCID tokens starting with _id #{response.results.to_a.first[:_id]}."
cursor = response.results.to_a.last[:sort]

response.records.each do |u|
DeleteTokenJob.perform_later(u.uid)
response.records.each do |user|
UserTokenJob.perform_later(user)
end
end
end
Expand Down

0 comments on commit 6e64e20

Please sign in to comment.