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

Update how partOf is added to a location #234

Merged
merged 1 commit into from
Jul 23, 2024
Merged
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
14 changes: 10 additions & 4 deletions importer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,16 @@ def location_extras(resource, payload_string):
longitude = "longitude"

try:
if locationParentName and locationParentName != "parentName":
payload_string = payload_string.replace(
"$parentName", locationParentName
).replace("$parentID", locationParentId)
if locationParentId and locationParentId != "parentId":
payload_string = payload_string.replace("$parentID", locationParentId)
if not locationParentName or locationParentName == "parentName":
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just mentioning here, that this implementation makes the assumption that if only the parentName is provided and the id is not provided, then it's okay to ignore it and remove the whole section

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this assumption is correct.

obj = json.loads(payload_string)
del obj["resource"]["partOf"]['display']
payload_string = json.dumps(obj, indent=4)
else:
payload_string = payload_string.replace(
"$parentName", locationParentName
)
else:
obj = json.loads(payload_string)
del obj["resource"]["partOf"]
Expand Down
Loading