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
1 change: 0 additions & 1 deletion .env.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ DATACITE_USAGE_SOURCE_TOKEN=
ZBMATH_RELATED_SOURCE_TOKEN=
ZBMATH_AUTHOR_SOURCE_TOKEN=
ZBMATH_IDENTIFIER_SOURCE_TOKEN=
EVENTDATA_TOKEN=
STAFF_ADMIN_TOKEN=
CROSSREF_SOURCE_ID=
CROSSREF_SOURCE_TOKEN=
17 changes: 0 additions & 17 deletions app/models/concerns/helpable.rb

This file was deleted.

1 change: 0 additions & 1 deletion app/models/crossref_import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def self.push_item(item)

Rails.logger.info push_items.inspect

# don't send to Event Data Bus
Array.wrap(push_items).each do |iiitem|
data = {
"data" => {
Expand Down
1 change: 0 additions & 1 deletion app/models/crossref_related.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ def self.push_item(item)

# there can be one or more references per DOI
# send to DataCite Event Data Query API
# don't send to Event Data Bus
Array.wrap(push_items).each do |iiitem|
data = {
"data" => {
Expand Down
25 changes: 0 additions & 25 deletions app/models/related_identifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ class RelatedIdentifier < Base
LICENSE = "https://creativecommons.org/publicdomain/zero/1.0/".freeze
DATACITE_CROSSREF = "datacite_crossref"

include Helpable
include Cacheable
include Queueable

Expand Down Expand Up @@ -143,30 +142,6 @@ def self.push_item(item)

Rails.logger.info "[Event Data] #{iiitem['subj_id']} #{iiitem['relation_type_id']} #{iiitem['obj_id']} sent to the events queue."

# send to Event Data Bus
# we only send datacite_crossref events to the bus
if ENV["EVENTDATA_TOKEN"].present? && iiitem["source_id"] == DATACITE_CROSSREF
iiitem = set_event_for_bus(iiitem)

host = ENV["EVENTDATA_URL"]
push_url = "#{host}/events"
response = Maremma.post(push_url, data: iiitem.to_json,
bearer: ENV["EVENTDATA_TOKEN"],
content_type: "json",
host: host)

# return 0 if successful, 1 if error
if response.status == 201
Rails.logger.info "[Event Data Bus] #{iiitem['subj_id']} #{iiitem['relation_type_id']} #{iiitem['obj_id']} pushed to Event Data service."
elsif response.status == 409
Rails.logger.info "[Event Data Bus] #{iiitem['subj_id']} #{iiitem['relation_type_id']} #{iiitem['obj_id']} already pushed to Event Data service."
elsif response.body["errors"].present?
Rails.logger.error "[Event Data Bus] #{iiitem['subj_id']} #{iiitem['relation_type_id']} #{iiitem['obj_id']} had an error:"
Rails.logger.error "[Event Data Bus] #{response.body['errors']}"
end
else
Rails.logger.info "[Event Data Bus] #{iiitem['subj_id']} #{iiitem['relation_type_id']} #{iiitem['obj_id']} was not sent to Event Data Bus."
end
end
push_items.length
end
Expand Down
1 change: 0 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
ENV["VOLPINO_URL"] ||= "https://api.stage.datacite.org"
ENV["LAGOTTINO_URL"] ||= "https://api.stage.datacite.org"
ENV["SASHIMI_QUERY_URL"] ||= "https://api.stage.datacite.org"
ENV["EVENTDATA_URL"] ||= "https://bus-staging.eventdata.crossref.org"
ENV["CROSSREF_QUERY_URL"] ||= "https://api.crossref.org"
ENV["TRUSTED_IP"] ||= "10.0.40.1"
ENV["SLACK_WEBHOOK_URL"] ||= ""
Expand Down
18 changes: 0 additions & 18 deletions spec/concerns/helpable_spec.rb

This file was deleted.

22 changes: 0 additions & 22 deletions spec/models/related_identifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@
allow(ENV).to receive(:[]).with("LAGOTTINO_URL").and_return("https://fake.lagattino.com")
allow(ENV).to receive(:[]).with("DATACITE_RELATED_SOURCE_TOKEN").and_return("DATACITE_RELATED_SOURCE_TOKEN")
allow(ENV).to receive(:[]).with("USER_AGENT").and_return("default_user_agent")
allow(ENV).to receive(:[]).with("EVENTDATA_TOKEN").and_return("EVENTDATA_TOKEN")
allow(ENV).to receive(:[]).with("EVENTDATA_URL").and_return("https://fake.eventdataurl.com")
allow(Base).to receive(:cached_datacite_response).and_return({ "foo" => "bar" })
allow(Maremma).to receive(:post).and_return(OpenStruct.new(status: 201))
allow(RelatedIdentifier).to receive(:send_event_import_message).and_return(nil)
Expand All @@ -108,26 +106,6 @@

expect(Rails.logger).to have_received(:info).with("[Event Data] https://doi.org/10.1234/example example_type https://doi.org/10.5678/related sent to the events queue.")
end

it "does push the event to the event data bus when source_id is datacite_crossref" do
related_identifier = RelatedIdentifier.new
allow(ENV).to receive(:[]).with("DATACITE_CROSSREF_SOURCE_TOKEN").and_return("fake-token")
allow(related_identifier).to receive(:normalize_doi).with(valid_doi).and_return("normalized_doi")
allow(related_identifier).to receive(:normalize_doi).with(valid_related_identifier).and_return("normalized_related_identifier")
allow(related_identifier).to receive(:validate_prefix).with(valid_related_identifier).and_return("datacite")
allow(RelatedIdentifier).to receive(:cached_doi_ra).with("https://doi.org/10.5678/related").and_return("Crossref")
allow(RelatedIdentifier).to receive(:cached_doi_ra).with("https://doi.org/10.1234/example").and_return("DataCite")
allow(RelatedIdentifier).to receive(:cached_crossref_response).and_return({})
allow(RelatedIdentifier).to receive(:cached_datacite_response).and_return({})
allow(related_identifier).to receive(:set_event_for_bus).and_return({})
allow(Rails.logger).to receive(:info)

expect(RelatedIdentifier.push_item(item)).to eq(1)
expect(RelatedIdentifier).to have_received(:send_event_import_message).once
expect(Maremma).to have_received(:post).with("https://fake.eventdataurl.com/events", anything).once
expect(Rails.logger).to have_received(:info).with("[Event Data] https://doi.org/10.1234/example example_type https://doi.org/10.5678/related sent to the events queue.")
expect(Rails.logger).to have_received(:info).with("[Event Data Bus] https://doi.org/10.1234/example example_type https://doi.org/10.5678/related pushed to Event Data service.")
end
end

context "when the DOI is blank" do
Expand Down
Loading