-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into handle-response
- Loading branch information
Showing
17 changed files
with
346 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class TransferClientJob < ActiveJob::Base | ||
queue_as :lupo_background | ||
|
||
def perform(client, options = {}) | ||
symbol = client.symbol | ||
|
||
if client.present? && options[:target_id].present? | ||
options = { | ||
filter: { client_id: symbol.downcase }, | ||
label: "[ClientTransfer]", | ||
job_name: "UpdateProviderIdJob", | ||
target_id: options[:target_id], | ||
} | ||
|
||
Doi.loop_through_dois(options) | ||
|
||
Rails.logger.info "[Transfer] DOIs updating has started for #{symbol} to #{options[:target_id]}." | ||
else | ||
Rails.logger.error "[Transfer] Error updating DOIs " + symbol + ": not found" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class UpdateProviderIdJob < ActiveJob::Base | ||
queue_as :lupo_transfer | ||
|
||
# retry_on ActiveRecord::RecordNotFound, wait: 10.seconds, attempts: 3 | ||
# retry_on Faraday::TimeoutError, wait: 10.minutes, attempts: 3 | ||
|
||
# discard_on ActiveJob::DeserializationError | ||
|
||
def perform(doi_id, options = {}) | ||
doi = Doi.where(doi: doi_id).first | ||
|
||
if doi.present? && options[:target_id].present? | ||
doi.__elasticsearch__.index_document | ||
|
||
Rails.logger.info "[Transfer] updated DOI #{doi.doi}." | ||
elsif doi.present? | ||
Rails.logger.error "[Transfer] Error updateding DOI " + doi_id + ": no target client" | ||
else | ||
Rails.logger.error "[Transfer] Error updateding DOI " + doi_id + ": not found" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require "factory_bot_rails" | ||
|
||
fail "Seed tasks can only be used in the development enviroment" if Rails.env.production? | ||
|
||
after "development:base" do | ||
|
||
provider = Provider.where(symbol: "QUECHUA").first || FactoryBot.create(:provider, symbol: "QUECHUA") | ||
client = Client.where(symbol: "QUECHUA.TEXT").first || FactoryBot.create(:client, provider: provider, symbol: "QUECHUA.TEXT", password: ENV["MDS_PASSWORD"]) | ||
if Prefix.where(uid: "10.14459").blank? | ||
prefix = FactoryBot.create(:prefix, uid: "10.14459") | ||
FactoryBot.create(:provider_prefix, provider_id: provider.symbol, prefix_id: prefix.uid) | ||
FactoryBot.create(:client_prefix, client_id: client.symbol, prefix_id: prefix.uid) | ||
end | ||
dois = FactoryBot.create_list(:doi, 10, client: client, state: "findable") | ||
FactoryBot.create_list(:event_for_datacite_related, 3, obj_id: dois.first.doi) | ||
FactoryBot.create_list(:event_for_datacite_usage, 2, obj_id: dois.first.doi) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.