Skip to content

Commit

Permalink
fix: metadata shouldn’t break if there are no notes
Browse files Browse the repository at this point in the history
  • Loading branch information
andylolz committed Aug 8, 2024
1 parent 5277bf9 commit 46c6841
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion output/about/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <time class="dt" datetime="{{ site.data.meta.most_recent }}" title="{{ site.data.meta.most_recent | date_to_rfc822 }}">{{ site.data.meta.most_recent }}</time>, scraped <time class="dt" datetime="{{ site.data.meta.scraped_at }}" title="{{ site.data.meta.scraped_at | date_to_rfc822 }}">{{ site.data.meta.scraped_at }}</time>**).
This data is always a couple of days old

{%- if site.data.meta.total_tweets -%}
(**most recent data is from <time class="dt" datetime="{{ site.data.meta.most_recent }}" title="{{ site.data.meta.most_recent | date_to_rfc822 }}">{{ site.data.meta.most_recent }}</time>, scraped <time class="dt" datetime="{{ site.data.meta.scraped_at }}" title="{{ site.data.meta.scraped_at | date_to_rfc822 }}">{{ site.data.meta.scraped_at }}</time>**)
{%- endif -%}
.

Notes are excluded if they meet any of the following criteria:

Expand Down
2 changes: 1 addition & 1 deletion x_notes/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 46c6841

Please sign in to comment.