Skip to content

Commit

Permalink
Merge 9486402 into 35d46dd
Browse files Browse the repository at this point in the history
  • Loading branch information
peetucket authored Mar 18, 2021
2 parents 35d46dd + 9486402 commit 4850862
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/smci_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def run
unless uids.empty? # check to see if there are any results
results = WebOfScience.queries.retrieve_by_id(uids) # now fetch the publication details for these WOS_UIDs
while results.next_batch? # as long as we have another page of results, retrieve them
results.next_batch.to_a.each { |pub| csv << output_row(pub_hash: pub.pub_hash) } # output all publications in this batch
results.next_batch.to_a.each { |pub| csv << output_row(pub_hash: pub.pub_hash, orcid: orcid) } # output all publications in this batch
end
end
# end check for any publications to fetch for this author
Expand All @@ -182,10 +182,10 @@ def run
private

def header_row
%w(title author_list pmid wos_uid sul_pub_id doi doi_url publisher journal volume articlenumber supplement issue pages mesh pub_year pub_date provenance profiles_author_last_name profiles_author_first_name profiles_author_sunet profiles_author_cap_profile_id profiles_author_employee_id profiles_author_email publication_status pub_harvested_date apa_citation mla_citation chicago_citation)
%w(title author_list pmid wos_uid sul_pub_id doi doi_url publisher journal volume articlenumber supplement issue pages mesh pub_year pub_date provenance orcid profiles_author_last_name profiles_author_first_name profiles_author_sunet profiles_author_cap_profile_id profiles_author_employee_id profiles_author_email publication_status pub_harvested_date apa_citation mla_citation chicago_citation)
end

def output_row(pub_hash:, harvested_at: Time.now.utc.to_s(:db), author: nil, publication_status: 'unknown')
def output_row(pub_hash:, harvested_at: Time.now.utc.to_s(:db), author: nil, orcid: nil, publication_status: 'unknown')
author_list = pub_hash[:author] ? Csl::RoleMapper.send(:parse_authors, pub_hash[:author]).map { |a| "#{a['family']}, #{a['given']}" }.join('; ') : ''
pmid = pub_hash[:identifier].map { |ident| ident[:id] if ident[:type].downcase == 'pmid' }.compact.join('')
doi = pub_hash[:identifier].map { |ident| ident[:id] if ident[:type].downcase == 'doi' }.compact.join('')
Expand Down Expand Up @@ -226,6 +226,7 @@ def output_row(pub_hash:, harvested_at: Time.now.utc.to_s(:db), author: nil, pub
pub_hash[:year],
pub_hash[:date],
pub_hash[:provenance],
orcid,
author_last_name,
author_first_name,
author_sunet,
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/smci_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@

it 'creates an output for a profile author' do
result = report.send(:output_row, pub_hash: pub_hash, author: author, harvested_at: date, publication_status: 'new')
expect(result).to eq(['some title', '', '', '', '', '', '', 'some publisher', '', '', '', '', nil, nil, '', nil, nil, nil, author.last_name, author.first_name, author.sunetid, author.cap_profile_id, author.university_id, author.email, 'new', date, nil, nil, nil])
expect(result).to eq(['some title', '', '', '', '', '', '', 'some publisher', '', '', '', '', nil, nil, '', nil, nil, nil, nil, author.last_name, author.first_name, author.sunetid, author.cap_profile_id, author.university_id, author.email, 'new', date, nil, nil, nil])
end

it 'creates an output row for a non-profile author' do
result = report.send(:output_row, pub_hash: pub_hash)
expect(result).to eq(['some title', '', '', '', '', '', '', 'some publisher', '', '', '', '', nil, nil, '', nil, nil, nil, '', '', '', '', '', '', 'unknown', Time.now.utc.to_s(:db), nil, nil, nil])
result = report.send(:output_row, orcid: '1234', pub_hash: pub_hash)
expect(result).to eq(['some title', '', '', '', '', '', '', 'some publisher', '', '', '', '', nil, nil, '', nil, nil, nil, '1234', '', '', '', '', '', '', 'unknown', Time.now.utc.to_s(:db), nil, nil, nil])
end
end
end

0 comments on commit 4850862

Please sign in to comment.