From 46c6841f9d85efff82d1b1049ec9565c3fb0a264 Mon Sep 17 00:00:00 2001 From: Andy Lulham Date: Thu, 8 Aug 2024 08:50:14 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20metadata=20shouldn=E2=80=99t=20break=20i?= =?UTF-8?q?f=20there=20are=20no=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- output/about/index.md | 7 ++++++- x_notes/meta.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/output/about/index.md b/output/about/index.md index d76e3020..287c1bca 100644 --- a/output/about/index.md +++ b/output/about/index.md @@ -4,7 +4,12 @@ title: How it works Community note data is fetched regularly [from Twitter (X)](https://x.com/i/communitynotes/download-data). -This data is always a couple of days old (**most recent data is from , scraped **). +This data is always a couple of days old + +{%- if site.data.meta.total_tweets -%} +(**most recent data is from , scraped **) +{%- endif -%} +. Notes are excluded if they meet any of the following criteria: diff --git a/x_notes/meta.py b/x_notes/meta.py index fce84934..b68df5d7 100644 --- a/x_notes/meta.py +++ b/x_notes/meta.py @@ -31,7 +31,7 @@ def update_meta(update: dict[str, Any]) -> None: def update_meta_from_notes(notes: dict[str, dict[str, Any]]) -> None: update = { "scraped_at": datetime.now(timezone.utc).isoformat(), - "most_recent": list(notes.values())[0]["created_at"], + "most_recent": list(notes.values())[0]["created_at"] if notes else None, "total_tweets": len({note["tweet_id"] for note in notes.values()}), "total_fetched": len( {note["tweet_id"] for note in notes.values() if "dl" in note}