From 31cbde0ba3bad71a7c062c5d57955cd8261941b8 Mon Sep 17 00:00:00 2001 From: Mark Pittaway Date: Mon, 30 Oct 2023 16:23:56 +1100 Subject: [PATCH 1/3] on_fetch: Store ingest_id even if `:` not in guid --- apps/duplication/archive_fetch.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/duplication/archive_fetch.py b/apps/duplication/archive_fetch.py index e14e7f5bd4..80a8df60ea 100644 --- a/apps/duplication/archive_fetch.py +++ b/apps/duplication/archive_fetch.py @@ -136,11 +136,10 @@ def __strip_version_from_guid(self, guid, version): Checks if guid contains the version for the ingested item and returns the guid without version """ try: - if not version: - return guid - - if guid.endswith(":{}".format(str(version))): + if version and guid.endswith(":{}".format(str(version))): return guid[: -1 * (len(str(version)) + 1)] + else: + return guid except Exception: return guid From 544982091fe3be591225f5680415b7ab78a20d01 Mon Sep 17 00:00:00 2001 From: Mark Pittaway Date: Mon, 30 Oct 2023 16:24:30 +1100 Subject: [PATCH 2/3] ninjs_newsroom: No option `extra.publish_ingest_id_as_guid` --- superdesk/publish/formatters/ninjs_newsroom_formatter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/superdesk/publish/formatters/ninjs_newsroom_formatter.py b/superdesk/publish/formatters/ninjs_newsroom_formatter.py index 328629a239..82b1b7561d 100644 --- a/superdesk/publish/formatters/ninjs_newsroom_formatter.py +++ b/superdesk/publish/formatters/ninjs_newsroom_formatter.py @@ -39,7 +39,9 @@ def _format_products(self, article): def _transform_to_ninjs(self, article, subscriber, recursive=True): ninjs = super()._transform_to_ninjs(article, subscriber, recursive) - if article.get("ingest_id") and article.get("auto_publish"): + if article.get("ingest_id") and ( + article.get("auto_publish") or (article.get("extra") or {}).get("publish_ingest_id_as_guid") + ): ninjs["guid"] = article.get("ingest_id") if article.get("ingest_version"): ninjs["version"] = article["ingest_version"] From 41ed3377fce354f66593eb5ff3a39979cb6181b8 Mon Sep 17 00:00:00 2001 From: Mark Pittaway Date: Mon, 30 Oct 2023 16:25:10 +1100 Subject: [PATCH 3/3] ninjs: Log error if failed to load json file --- superdesk/io/feed_parsers/ninjs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/superdesk/io/feed_parsers/ninjs.py b/superdesk/io/feed_parsers/ninjs.py index 42d14199c1..58511cf25f 100644 --- a/superdesk/io/feed_parsers/ninjs.py +++ b/superdesk/io/feed_parsers/ninjs.py @@ -61,7 +61,9 @@ def can_parse(self, file_path): ninjs = json.load(f) if ninjs.get("uri") or ninjs.get("guid"): return True - except Exception: + except Exception as err: + logger.exception(err) + logger.error("Failed to ingest json file") pass return False