fix: handle missing comments key when syncing rants with no comments
The previous code assumed every rant returned from the API would have a "comments" key, causing a KeyError crash when iterating over rants that had zero comments. This fix uses `.get("comments", [])` to safely default to an empty list, allowing the sync loop to continue without interruption.
This commit is contained in:
parent
ed190ec774
commit
2657c83053
@ -62,7 +62,7 @@ async def sync_comments():
|
||||
rants_synced = 0
|
||||
for rant in db["rants"].find(order_by="-id"):
|
||||
rants_synced += 1
|
||||
comments = dr.get_rant(rant["id"])["comments"]
|
||||
comments = dr.get_rant(rant["id"]).get("comments",[])
|
||||
for comment in comments:
|
||||
comments_synced += 1
|
||||
comment["created"] = timestamp_to_string(comment["created_time"])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user