Skip to content

Commit

Permalink
Improve logging output of Contentful sync to spot what fields might b…
Browse files Browse the repository at this point in the history
…e missing (mozilla#13838)

Example output:

Checking pagePageResourceCenter:nl:55qRE7t9g7lR64HY49kjFk-> Localised? False
These fields were missing localised content: {'.info.seo.description'}
  • Loading branch information
stevejalim authored Oct 27, 2023
1 parent bb88b6b commit 7464c07
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bedrock/contentful/management/commands/update_contentful.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,20 +359,27 @@ def _check_localisation_complete(self) -> None:
seen_count += 1
if completeness_spec:
viable_for_localisation_count += 1
entry_localised_fields_found = set()
data = contentful_entry.data
collected_values = []
for step in completeness_spec:
collected_values.append(self._get_value_from_data(data, step))
_value_for_step = self._get_value_from_data(data, step)
if _value_for_step:
entry_localised_fields_found.add(step)
collected_values.append(_value_for_step)
contentful_entry.localisation_complete = all(collected_values)
contentful_entry.save()
if contentful_entry.localisation_complete:
localisation_complete_count += 1
else:
localisation_not_configured_count += 1
self.log(
f"Checking {contentful_entry.content_type}:{contentful_entry.locale}:{contentful_entry.contentful_id}"
f"\nChecking {contentful_entry.content_type}:{contentful_entry.locale}:{contentful_entry.contentful_id}"
f"-> Localised? {contentful_entry.localisation_complete}"
)
if completeness_spec and not contentful_entry.localisation_complete:
_missing_fields = set(completeness_spec).difference(entry_localised_fields_found)
self.log(f"These fields were missing localised content: {_missing_fields}")

self.log(
(
Expand Down

0 comments on commit 7464c07

Please sign in to comment.