diff --git a/invenio_vocabularies/contrib/names/datastreams.py b/invenio_vocabularies/contrib/names/datastreams.py index 2c7c9288..cf5b9fde 100644 --- a/invenio_vocabularies/contrib/names/datastreams.py +++ b/invenio_vocabularies/contrib/names/datastreams.py @@ -266,15 +266,17 @@ 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 is already in result + if aff_id and any(aff.get("id") == aff_id 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