Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Commit

Permalink
Handles missing or null grant agency.
Browse files Browse the repository at this point in the history
closes #368
  • Loading branch information
justinlittman committed Feb 5, 2019
1 parent 05d886e commit 8a06cf9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/rialto/etl/configs/wos_to_sparql_statements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ def parse_address(addr)
# Find the grant agencies
def fetch_grant_agencies(json)
agencies = Array.wrap(JsonPath.on(json, '$.static_data.fullrecord_metadata.fund_ack.grants.grant').first).map do |grant|
next if grant.fetch('grant_agency', []).empty?
grant['grant_agency']
grant_agency = grant['grant_agency']
next if grant_agency.nil? || grant_agency.empty?
grant_agency
end
agencies.compact
end
Expand Down
5 changes: 3 additions & 2 deletions spec/configs/wos_to_sparql_statements_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ def transform(source_file)
it { is_expected.to eq(['National Institute of Diabetes and Digestive and Kidney Diseases']) }
end

context 'with no grant agency' do
context 'with null grant agency' do
let(:json) do
<<~JSON
{
Expand All @@ -719,7 +719,8 @@ def transform(source_file)
"grant_ids": {
"grant_id": ["U01DK073983", "U01DK073975", "U01DK073985", "U01DK074007", "U01DK073974", "U01DK074008"],
"count": 6
}
},
"grant_agency": null
}
}
}
Expand Down

0 comments on commit 8a06cf9

Please sign in to comment.