Skip to content

Commit

Permalink
names: improve affiliations deduplication
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcastro2 committed Dec 6, 2024
1 parent 449dc5b commit b798bf3
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions invenio_vocabularies/contrib/names/datastreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,23 @@ def _extract_affiliations(self, record):
continue

org = employment["organization"]
aff = {"name": org["name"]}

# Extract the org ID, to link to the affiliation vocabulary
aff_id = self._extract_affiliation_id(org)

# Skip adding if the ID already exists in result
if aff_id and any(aff.get("id") == aff_id for aff in result):
continue

# Skip adding if the name exists in result with no ID
if any(
aff.get("name") == org["name"] and "id" not in aff for aff in result
):
continue

aff = {"name": org["name"]}
if aff_id:
aff["id"] = aff_id

if aff not in result:
result.append(aff)
result.append(aff)
except Exception:
pass
return result
Expand Down

0 comments on commit b798bf3

Please sign in to comment.