Skip to content

Commit

Permalink
orcid provenance in settings, and convenience methods
Browse files Browse the repository at this point in the history
  • Loading branch information
peetucket committed Jul 26, 2023
1 parent 92a31e0 commit c92a741
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
4 changes: 4 additions & 0 deletions app/models/publication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ def pubmed_pub?
provenance == Settings.pubmed_source
end

def orcid_pub?
provenance == Settings.orcid_source
end

def wos_pub?
provenance == Settings.wos_source
end
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ cap_provenance: cap
pubmed_source: pubmed
sciencewire_source: sciencewire
wos_source: wos
orcid_source: orcid

# checkin keys for honeybadger (actual keys are in shared_configs per environment as needed)
# see https://app.honeybadger.io/projects/50046/check_ins
Expand Down
2 changes: 1 addition & 1 deletion lib/orcid/work_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def map
title: work.title,
identifier: map_identifiers(work.self_external_ids),
abstract: work.short_description,
provenance: 'orcid',
provenance: Settings.orcid_source,
doi: work.external_id_value('doi'),
isbn: work.external_id_value('isbn'),
issn: work.external_id_value('issn'),
Expand Down
14 changes: 7 additions & 7 deletions pub_hash_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ properties:
enum:
- article
- book
- caseStudy # Potential legacy. Only set via manual pub submission (provenance = CAP)
- caseStudy # Only set via manual pub submission (provenance = cap)
- inproceedings
- inbook # Potential legacy. Only set via manual pub submission (provenance = CAP)
- otherpaper # Legacy. Likely bad data.
- otherPaper # Potential legacy. Only set via manual pub submission (provenance = CAP)
- technicalReport # Potential legacy. Only set via manual pub submission (provenance = CAP)
- workingPaper # Potential legacy. Only set via manual pub submission (provenance = CAP)
- null # Legacy. Not in current code.
- inbook # Only set via manual pub submission (provenance = cap)
- otherpaper # Legacy. Not in current code, likely bad data.
- otherPaper # Only set via manual pub submission (provenance = cap) or via ORCID harvest (provenance = orcid)
- technicalReport # Only set via manual pub submission (provenance = cap) or via ORCID harvest (provenance = orcid)
- workingPaper # Only set via manual pub submission (provenance = cap) or via ORCID harvest (provenance = orcid)
- null # Legacy. Not in current code, likely bad data.
wos_item_id:
type: string
wos_uid:
Expand Down
12 changes: 11 additions & 1 deletion spec/lib/orcid/pub_mapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,24 @@

context 'when unmappable type' do
let(:pub_hash) do
base_pub_hash.dup.tap { |pub_hash| pub_hash[:type] = nil }
base_pub_hash.dup.tap { |pub_hash| pub_hash[:type] = 'unknownType' }
end

it 'raises' do
expect { work }.to raise_error(Orcid::PubMapper::PubMapperError, 'Unmapped publication type')
end
end

context 'when mappable type' do
let(:pub_hash) do
base_pub_hash.dup.tap { |pub_hash| pub_hash[:type] = 'workingPaper' }
end

it 'maps correctly' do
expect(work['type']).to eq('working-paper')
end
end

context 'when missing title' do
let(:pub_hash) { base_pub_hash.except(:title) }

Expand Down
7 changes: 7 additions & 0 deletions spec/models/publication_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,13 @@
expect(pub).to be_harvested_pub
end

it "returns true if the pub has a provenance of 'orcid'" do
pub.pub_hash = { provenance: 'orcid' }
expect(pub).not_to be_authoritative_pmid_source
expect(pub).to be_orcid_pub
expect(pub).to be_harvested_pub
end

it "returns false if the pub does not have a provanance of 'pubmed' or 'sciencewire'" do
pub.pub_hash = { provenance: 'cap' }
expect(pub).not_to be_authoritative_pmid_source
Expand Down

0 comments on commit c92a741

Please sign in to comment.