Basic support for house priority campaigns.

This commit is contained in:
Brian Simpson
2013-11-06 21:24:37 -05:00
parent 5caf5502dd
commit dda49c68ad

View File

@@ -764,7 +764,10 @@ def get_live_promotions(sr_names):
def lottery_promoted_links(sr_names, n=10):
"""Run weighted_lottery to order and choose a subset of promoted links."""
promo_tuples = get_live_promotions(sr_names)
weights = {p: p.weight for p in promo_tuples if p.weight}
# house priority campaigns have weight of 0, use some small value
# so they'll show if there are no other campaigns
weights = {p: p.weight or 0.001 for p in promo_tuples}
selected = []
while weights and len(selected) < n:
s = weighted_lottery(weights)