Skip to content

Commit

Permalink
handle archived kills
Browse files Browse the repository at this point in the history
  • Loading branch information
marwoodandrew committed Jan 23, 2024
1 parent d46cbd6 commit 4f5d740
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 68 deletions.
4 changes: 2 additions & 2 deletions server/aap/publish/formatters/aap_apple_news_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _remove_embeds(self, article, remove_keys):

for key in remove_keys:
article.get("associations", {}).pop(key, None)
if "refs" in article:
if article.get("refs") is not None:
article["refs"] = [r for r in article.get("refs", []) if r["key"] != key]

def _remove_unwanted_embeds(self, article):
Expand All @@ -105,7 +105,7 @@ def _remove_unwanted_embeds(self, article):
remove_keys = []

# can only handle pictures at the moment
for key, item in article.get("associations", {}).items():
for key, item in (article.get("associations") or {}).items():
if key.startswith("editor_") and item.get("type") != 'picture':
remove_keys.append(key)

Expand Down
14 changes: 10 additions & 4 deletions server/aap/publish/transmitters/http_push_apple_news.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,17 @@ def _get_item(self, queue_item):
)

def _get_original_guid(self, item):
"""
Chase up the rewrite list until we get to the orignal in either the archive or legal archive (if the item has
expired from production
:param item:
:return:
"""
guid = item.get('rewrite_of', item.get('guid', item.get('item_id', None)))
for i in range(item.get('rewrite_sequence', 1)):
prev = get_resource_service('archive').find_one(
req=None, _id=guid
)
for _i in range(item.get('rewrite_sequence', 1)):
prev = get_resource_service('archive').find_one(req=None, _id=guid)
if not prev:
prev = get_resource_service('legal_archive').find_one(req=None, _id=guid)
if not prev or not prev.get('rewrite_of'):
break
guid = prev['rewrite_of']
Expand Down
62 changes: 0 additions & 62 deletions server/aap/tests/io/fixtures/dc_response.xml

This file was deleted.

0 comments on commit 4f5d740

Please sign in to comment.