Skip to content

Commit

Permalink
Merge pull request #159 from lsst-sqre/tickets/DM-42705
Browse files Browse the repository at this point in the history
DM-42705: Fall back to using current date for update_time
  • Loading branch information
jonathansick authored Jan 29, 2024
2 parents 5bcc93e + 10b18dc commit a542c17
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

<!-- scriv-insert-here -->

<a id='changelog-0.9.1'></a>
## 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.

<a id='changelog-0.9.0'></a>
## 0.9.0 (2023-09-26)

Expand Down
15 changes: 10 additions & 5 deletions src/ook/domain/ltdtechnote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a542c17

Please sign in to comment.