Skip to content

Commit

Permalink
Merge pull request #850 from sul-dlss/nuke_sciencewire
Browse files Browse the repository at this point in the history
Nuke sciencewire
  • Loading branch information
jcoyne authored Mar 18, 2019
2 parents 1397aca + 1b30158 commit 5075155
Show file tree
Hide file tree
Showing 75 changed files with 7,731 additions and 10,792 deletions.
5 changes: 0 additions & 5 deletions app/controllers/publications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ def sourcelookup
all_matching_records += wos_matches
logger.debug(" -- WOS (#{wos_matches.length})")
end
if Settings.SCIENCEWIRE.enabled
sw_matches = ScienceWireClient.new.query_sciencewire_for_publication(nil, nil, nil, params[:title], params[:year], params.fetch(:max_rows, 20).to_i)
all_matching_records += sw_matches
logger.debug(" -- sciencewire (#{sw_matches.length})")
end
# lastly, always check for manual
results = Publication.joins(:user_submitted_source_records)
.where(UserSubmittedSourceRecord.arel_table[:title].matches("%#{params[:title]}%"))
Expand Down
12 changes: 0 additions & 12 deletions app/jobs/author_harvest_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def perform(cap_profile_id, harvest_alternate_names: false)
author = Author.find_by(cap_profile_id: cap_profile_id)
author ||= Author.fetch_from_cap_and_create(cap_profile_id)
raise "Could not find or fetch author: #{cap_profile_id}" unless author.is_a?(Author)
sciencewire(author, harvest_alternate_names)
web_of_science(author, harvest_alternate_names)
rescue => e
msg = "AuthorHarvestJob.perform(#{cap_profile_id}, harvest_alternate_names: #{harvest_alternate_names})"
Expand All @@ -29,17 +28,6 @@ def log_pubs(author)
logger.info "Number of publications #{pubs.count}"
end

# @param [Author] author
# @param [Boolean] harvest_alternate_names
# @return [void]
def sciencewire(author, harvest_alternate_names)
return unless Settings.SCIENCEWIRE.enabled
harvester = ScienceWireHarvester.new
harvester.use_author_identities = harvest_alternate_names
harvester.harvest_pubs_for_author_ids author.id
log_pubs(author)
end

# @param [Author] author
# @param [Boolean] _harvest_alternate_names
# @return [void]
Expand Down
67 changes: 3 additions & 64 deletions app/models/sciencewire_source_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,7 @@ def publication_xml
# is_active, source_data and the source_fingerprint fields.
# @return [Boolean] the return value from update_attributes!
def sciencewire_update
sw_record_doc = ScienceWireClient.new.get_sw_xml_source_for_sw_id(sciencewire_id)
sw_pub = ScienceWirePublication.new sw_record_doc
attrs = {}
attrs[:pmid] = sw_pub.pmid unless sw_pub.pmid.blank?
attrs[:is_active] = !sw_pub.obsolete?
attrs[:source_data] = sw_pub.to_xml
attrs[:source_fingerprint] = Digest::SHA2.hexdigest(sw_record_doc)
update_attributes! attrs
raise 'ScienceWire has been decommissioned!'
end

##
Expand Down Expand Up @@ -75,69 +68,15 @@ def self.get_pub_by_sciencewire_id(sciencewire_id)
end

def self.get_sciencewire_hash_for_sw_id(sciencewire_id)
sciencewire_source_record = get_sciencewire_source_record_for_sw_id(sciencewire_id)
sciencewire_source_record = find_by(sciencewire_id: sciencewire_id)
sciencewire_source_record.source_as_hash unless sciencewire_source_record.nil?
end

def self.get_sciencewire_hash_for_pmid(pmid)
sciencewire_source_record = get_sciencewire_source_record_for_pmid(pmid)
sciencewire_source_record = find_by(pmid: pmid)
sciencewire_source_record.source_as_hash unless sciencewire_source_record.nil?
end

def self.get_sciencewire_source_record_for_sw_id(sw_id)
find_by(sciencewire_id: sw_id) || get_sciencewire_source_record_from_sciencewire_by_sw_id(sw_id)
end

def self.get_sciencewire_source_record_for_pmid(pmid)
find_by(pmid: pmid) || get_sciencewire_source_record_from_sciencewire(pmid)
end

def self.get_sciencewire_source_record_from_sciencewire(pmid)
get_and_store_sw_source_records([pmid])
find_by(pmid: pmid)
end

def self.get_sciencewire_source_record_from_sciencewire_by_sw_id(sciencewire_id)
get_and_store_sw_source_record_for_sw_id(sciencewire_id)
find_by(sciencewire_id: sciencewire_id)
end

def self.get_and_store_sw_source_record_for_sw_id(sciencewire_id)
sw_record_doc = ScienceWireClient.new.get_sw_xml_source_for_sw_id(sciencewire_id)
pmid = extract_pmid(sw_record_doc)
where(sciencewire_id: sciencewire_id).first_or_create(
source_data: sw_record_doc.to_xml,
is_active: true,
pmid: pmid,
source_fingerprint: Digest::SHA2.hexdigest(sw_record_doc))
end
private_class_method :get_and_store_sw_source_record_for_sw_id

# get and store sciencewire source records for pmid list
def self.get_and_store_sw_source_records(pmids)
sw_records_doc = ScienceWireClient.new.pull_records_from_sciencewire_for_pmids(pmids)
count = 0
source_records = []
sw_records_doc.xpath('//PublicationItem').each do |sw_record_doc|
pmid = extract_pmid(sw_record_doc)
sciencewire_id = extract_swid(sw_record_doc)
begin
count += 1
pmids.delete(pmid)
source_records << SciencewireSourceRecord.new(
sciencewire_id: sciencewire_id,
source_data: sw_record_doc.to_xml,
is_active: true,
pmid: pmid,
source_fingerprint: Digest::SHA2.hexdigest(sw_record_doc))
rescue => e
NotificationManager.error(e, "Cannot create SciencewireSourceRecord: sciencewire_id: #{sciencewire_id}, pmid: #{pmid}", self)
end
end
import source_records
end
private_class_method :get_and_store_sw_source_records

def self.save_sw_source_record(sciencewire_id, pmid, incoming_sw_xml_as_string)
existing_sw_source_record = find_by(
sciencewire_id: sciencewire_id)
Expand Down
1 change: 0 additions & 1 deletion config/initializers/okcomputer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def check
Cap::Client,
PubmedClient
]
clients << ScienceWireClient if Settings.SCIENCEWIRE.enabled
if Settings.WOS.enabled
clients << WebOfScience
clients << Clarivate::LinksClient
Expand Down
3 changes: 1 addition & 2 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ PUBMED:

## Sciencewire Auth Config
SCIENCEWIRE:
enabled: true
enabled: false
LOG: log/sciencewire.log
BASE_URI: https://sciencewirerest.discoverylogic.com
HOST: stg.sciencewirerest.discoverylogic.com
LICENSE_ID: some-license-id
RECOMMENDATION_PATH: /PublicationCatalog/MatchedPublicationItemIdsForAuthor?format=xml
TMPDIR: /tmp
ARTICLE_BASE_URI: https://ws.isiknowledge.com/cps/openurl/service?url_ver=Z39.88-2004&rft_id=info:ut/
Expand Down

This file was deleted.

Loading

0 comments on commit 5075155

Please sign in to comment.