Skip to content

Commit

Permalink
change order and type of preferred ids from orcid
Browse files Browse the repository at this point in the history
  • Loading branch information
vincerubinetti committed May 7, 2024
1 parent 8d507c2 commit 579bbc2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Reference: common-changelog.org
- Simplify portrait component under-the-hood.
- Make tag component de-duplication consistent with search plugin de-duplication.
- Expand list of supported Manubot identifiers and thus keep ORCID API details less often.
- Change order and type of preferred ids from ORCID API.

## 1.2.1 - 2024-04-01

Expand Down
17 changes: 13 additions & 4 deletions _cite/plugins/orcid.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,25 @@ def query(_id):
# go through response structure and pull out ids e.g. doi:1234/56789
for work in response:
# get list of ids
ids = get_safe(work, "external-ids.external-id", [])
ids = []
for summary in get_safe(work, "work-summary", []):
ids = ids + get_safe(summary, "external-ids.external-id", [])
ids = ids + get_safe(work, "external-ids.external-id", [])

# prefer doi id type, or fallback to first id
# prefer particular "relationship" type, or fallback to first id
_id = next(
(id for id in ids if get_safe(id, "external-id-type", "") == "doi"),
ids[0] if len(ids) > 0 else {},
(
id
for id in ids
if get_safe(id, "external-id-relationship", "")
in ["self", "version-of", "part-of"]
),
ids[0] if len(ids) > 0 else None,
)

if _id == None:
continue

# get id and id-type from response
id_type = get_safe(_id, "external-id-type", "")
id_value = get_safe(_id, "external-id-value", "")
Expand Down

0 comments on commit 579bbc2

Please sign in to comment.