Check for valid campaign when fetching bid history

Occasional rogue promotion weights were causing /promoted/graph to fail. We
should figure out how those weights are being created in the first place, but
for now just check to make sure a campaign exists before using it.
This commit is contained in:
shlurbee
2012-07-17 13:39:03 -07:00
committed by bsimpson63
parent 6890bb56b1
commit b5812e6fa5

View File

@@ -565,7 +565,11 @@ class PromotionWeights(Sessionized, Base):
for i in q:
if d == i.date:
l = links[i.thing_name]
if not promote.is_rejected(l) and not promote.is_unpaid(l) and not l._deleted:
if (not promote.is_rejected(l) and
not promote.is_unpaid(l) and
not l._deleted and
i.promo_idx in getattr(l, 'campaigns', {})):
camp = l.campaigns[i.promo_idx]
bid += i.bid
refund += i.bid if camp[-1] <= 0 else 0