Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

awards: rollback to use the 2nd part of funding stream as program #420

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
5 changes: 4 additions & 1 deletion invenio_vocabularies/contrib/awards/datastreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def apply(self, stream_entry, **kwargs):

funding = next(iter(record.get("funding", [])), None)
if funding:
program = funding.get("fundingStream", {}).get("id", "")
funding_stream_id = funding.get("fundingStream", {}).get("id", "")
# Example funding stream ID: `EC::HE::HORIZON-AG-UN`. We need the `HE`
# string, i.e. the second "part" of the identifier.
program = next(iter(funding_stream_id.split("::")[1:2]), "")
if program:
award["program"] = program

Expand Down
4 changes: 2 additions & 2 deletions tests/contrib/awards/test_awards_datastreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def expected_from_award_json():
"id": "021nxhr62::0751743",
"identifiers": [{"identifier": "https://test.com", "scheme": "url"}],
"number": "0751743",
"program": "NSF::GEO/OAD::GEO/OCE",
"program": "GEO/OAD",
"title": {"en": "Test title"},
"funder": {"id": "021nxhr62"},
"acronym": "TA",
Expand All @@ -110,7 +110,7 @@ def expected_from_award_json_ec():
"title": {"en": "Test title"},
"funder": {"id": "00k4n6c32"},
"acronym": "TS",
"program": "TST::test::test",
"program": "test",
}


Expand Down