Skip to content

Commit

Permalink
fix: only update most_recent if we have a value
Browse files Browse the repository at this point in the history
  • Loading branch information
andylolz committed Aug 8, 2024
1 parent 2c3d992 commit 9b55753
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion x_notes/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ 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"] 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}
),
}

if update["total_tweets"]:
update["most_recent"] = list(notes.values())[0]["created_at"]

update_meta(update)

0 comments on commit 9b55753

Please sign in to comment.