From 6e64e206c0d14b7d008a7bac094025a2b4385939 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Fri, 11 Jun 2021 08:50:36 +0200 Subject: [PATCH] fix background job for token deletion --- app/jobs/user_token_job.rb | 2 +- app/models/user.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/jobs/user_token_job.rb b/app/jobs/user_token_job.rb index 3b319f58..11a3a1bd 100644 --- a/app/jobs/user_token_job.rb +++ b/app/jobs/user_token_job.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 857bef84..744badf8 100755 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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