From 98da601540ecd43c5d543aeea2606302ef8d9f8e Mon Sep 17 00:00:00 2001 From: dat972 Date: Tue, 10 Mar 2026 07:54:26 -0500 Subject: [PATCH] handling the fact that Pushpull can return duplicates, so we added a dedupe --- backend/worker/monitor.py | 5 +++++ 1 file changed, 5 insertions(+) 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,