diff --git a/backend/worker/monitor.py b/backend/worker/monitor.py index 0892595..5e36af1 100644 --- a/backend/worker/monitor.py +++ b/backend/worker/monitor.py @@ -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,