From f6929d30b99eb96f8da4dba514fbcbf3f1a489ae Mon Sep 17 00:00:00 2001 From: Jonathan Sick Date: Mon, 29 Jan 2024 14:46:06 -0500 Subject: [PATCH 1/2] Fall back to using current date for update_time --- changelog.d/20240129_141830_jsick_DM_42705.md | 3 +++ src/ook/domain/ltdtechnote.py | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 changelog.d/20240129_141830_jsick_DM_42705.md diff --git a/changelog.d/20240129_141830_jsick_DM_42705.md b/changelog.d/20240129_141830_jsick_DM_42705.md new file mode 100644 index 0000000..7d0fb1e --- /dev/null +++ b/changelog.d/20240129_141830_jsick_DM_42705.md @@ -0,0 +1,3 @@ +### Bug fixes + +- If a technote doesn't have the `og:article:modified_time` then Ook falls back to using the current time of ingest. This fallback is to meet the schema for the www.lsst.io website, and ideally documents should always set modification time metadata. diff --git a/src/ook/domain/ltdtechnote.py b/src/ook/domain/ltdtechnote.py index dc45ab4..7b5120c 100644 --- a/src/ook/domain/ltdtechnote.py +++ b/src/ook/domain/ltdtechnote.py @@ -68,11 +68,16 @@ def update_time(self) -> datetime: """The document's update time.""" key = "og:article:modified_time" try: - dt = datetime.fromisoformat( - self._html.cssselect(f"meta[property='{key}']")[-1].get( - "content" - ) - ) + date_text = self._html.cssselect(f"meta[property='{key}']")[ + -1 + ].get("content") + except Exception: + # The modified time may not be available. Fall back "now" on + # the assumption the document ingest is triggered by a + # documentation update + return datetime.now(tz=UTC) + try: + dt = datetime.fromisoformat(date_text) if dt.tzinfo is None: dt = dt.replace(tzinfo=UTC) except Exception as e: From 10b18dc12c10954ac13779db8a66b55b7b2ecddb Mon Sep 17 00:00:00 2001 From: Jonathan Sick Date: Mon, 29 Jan 2024 15:15:28 -0500 Subject: [PATCH 2/2] Prepare 0.9.1 release --- CHANGELOG.md | 7 +++++++ changelog.d/20240129_141830_jsick_DM_42705.md | 3 --- 2 files changed, 7 insertions(+), 3 deletions(-) delete mode 100644 changelog.d/20240129_141830_jsick_DM_42705.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b5f365..ee67dd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ + +## 0.9.1 (2024-01-29) + +### Bug fixes + +- If a technote doesn't have the `og:article:modified_time` then Ook falls back to using the current time of ingest. This fallback is to meet the schema for the www.lsst.io website, and ideally documents should always set modification time metadata. + ## 0.9.0 (2023-09-26) diff --git a/changelog.d/20240129_141830_jsick_DM_42705.md b/changelog.d/20240129_141830_jsick_DM_42705.md deleted file mode 100644 index 7d0fb1e..0000000 --- a/changelog.d/20240129_141830_jsick_DM_42705.md +++ /dev/null @@ -1,3 +0,0 @@ -### Bug fixes - -- If a technote doesn't have the `og:article:modified_time` then Ook falls back to using the current time of ingest. This fallback is to meet the schema for the www.lsst.io website, and ideally documents should always set modification time metadata.