Skip to content

Commit

Permalink
Improve docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelboca committed Mar 13, 2023
1 parent 34fa490 commit 62a16d0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ckanext/harvest/plugin/__init__.py
Expand Up @@ -134,11 +134,11 @@ def before_dataset_index(self, pkg_dict):
This method will add or update harvest related metadata in `pkg_dict`,
`data_dict` and `validated_data_dict` so it can be obtained when
calling package_show API (that depends on Solr data). This metadata will
be stored in the `extra` field of the dictionaries.
be stored in the `extras` field of the dictionaries ONLY if it does not
already exist in the root schema.
By default all harvest metadata will go in the extra field. If
another extension adds any of them to the `package_show` schema
then it will not be added again in the `extras` field to avoid
Note: If another extension adds any harvest extra to the `package_show`
schema then this method will add them again in the `extras` field to avoid
validation errors when updating a package.
"""
# Fix to support Solr8
Expand All @@ -164,15 +164,13 @@ def before_dataset_index(self, pkg_dict):
("harvest_source_title", harvest_object.source.title),
]

# Add harvest extras to data_dict
data_dict = json.loads(pkg_dict["data_dict"])
for key, value in harvest_extras:
if key in data_dict.keys():
data_dict[key] = value
continue
self._add_or_update_harvest_metadata(key, value, data_dict)

# Add harvest extras to validated_data_dict
validated_data_dict = json.loads(pkg_dict["validated_data_dict"])
for key, value in harvest_extras:
if key in validated_data_dict.keys():
Expand Down

0 comments on commit 62a16d0

Please sign in to comment.