From 3beee33287553ea648a32066703006b2f9657d5d Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Mon, 20 Aug 2012 12:32:44 -0700 Subject: [PATCH] Log vislink builder skipped occurrences. It appears that sometimes vislink is being skipped by the builder, leading to a blank ad box. I discovered this because the interest bar code would raise an exception upon the occurrence. I'd like to log this case to gauge how often this is occurring. --- r2/r2/controllers/listingcontroller.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/r2/r2/controllers/listingcontroller.py b/r2/r2/controllers/listingcontroller.py index 164d1e2c0..2a978e7ef 100755 --- a/r2/r2/controllers/listingcontroller.py +++ b/r2/r2/controllers/listingcontroller.py @@ -324,16 +324,19 @@ class HotController(FixListing, ListingController): max_num = self.listing_obj.max_num, max_score = self.listing_obj.max_score).listing() - has_subscribed = c.user.has_subscribed - promo_visible = promote.is_promo(s.lookup[vislink]) - if not promo_visible: - prob = g.live_config['spotlight_interest_sub_p' - if has_subscribed else - 'spotlight_interest_nosub_p'] - if random.random() < prob: - bar = InterestBar(has_subscribed) - s.spotlight_items.insert(pos, bar) - s.visible_item = bar + if vislink not in s.lookup: + g.log.error("spotlight vislink skipped by builder: %s" % vislink) + else: + has_subscribed = c.user.has_subscribed + promo_visible = promote.is_promo(s.lookup[vislink]) + if not promo_visible: + prob = g.live_config['spotlight_interest_sub_p' + if has_subscribed else + 'spotlight_interest_nosub_p'] + if random.random() < prob: + bar = InterestBar(has_subscribed) + s.spotlight_items.insert(pos, bar) + s.visible_item = bar if len(s.things) > 0: # only pass through a listing if the links made it