From 57714d47d920099a0a366b6e88e06d4c5fb39c0c Mon Sep 17 00:00:00 2001 From: Brian Simpson Date: Tue, 3 Mar 2015 19:43:40 -0500 Subject: [PATCH] AdsController: don't show duplicate ads. --- r2/r2/controllers/listingcontroller.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/r2/r2/controllers/listingcontroller.py b/r2/r2/controllers/listingcontroller.py index 790396f9d..77e5e980d 100644 --- a/r2/r2/controllers/listingcontroller.py +++ b/r2/r2/controllers/listingcontroller.py @@ -593,7 +593,12 @@ class AdsController(SubredditListingController): def keep_fn(self): def keep(item): - return item.promoted and not item._deleted + if item._fullname in self.promos: + return False + if item.promoted and not item._deleted: + self.promos.add(item._fullname) + return True + return False return keep def query(self): @@ -607,6 +612,10 @@ class AdsController(SubredditListingController): promote.add_trackers(listing.things, c.site) return listing + def GET_listing(self, *a, **kw): + self.promos = set() + return SubredditListingController.GET_listing(self, *a, **kw) + class RandomrisingController(ListingWithPromos): where = 'randomrising'