handling the fact that Pushpull can return duplicates, so we added a dedupe

This commit is contained in:
2026-03-10 07:54:26 -05:00
parent 43f716a58a
commit 98da601540

View File

@@ -70,6 +70,11 @@ def _parse_post(post_data: dict, subreddit_id: int, db: Session, hot_rank: int |
def _upsert_posts(db: Session, posts: list[dict], update_hot_rank: bool = False):
if not posts:
return
# Deduplicate by reddit_id (Pullpush can return dupes)
seen = {}
for p in posts:
seen[p["reddit_id"]] = p
posts = list(seen.values())
update_set = {
"score": insert(Post).excluded.score,
"upvote_ratio": insert(Post).excluded.upvote_ratio,