Skip to content

Commit

Permalink
Ads: Remove un-targeting keywords for selfserve ad requests only
Browse files Browse the repository at this point in the history
  • Loading branch information
dwick committed Dec 10, 2015
1 parent 555d65d commit 21dd731
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions r2/r2/lib/promote.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,22 +1024,24 @@ def srnames_from_site(user, site, include_subscriptions=True):
return srnames


def srnames_with_live_promos(user, site, include_subscriptions=True):
site_srnames = srnames_from_site(
def keywords_from_context(
user, site,
include_subscriptions,
)
promo_srnames = all_live_promo_srnames()
return promo_srnames.intersection(site_srnames)

include_subscriptions=True,
live_promos_only=True,
):

def keywords_from_context(user, site, include_subscriptions=True):
keywords = srnames_with_live_promos(
user,
site,
keywords = srnames_from_site(
user, site,
include_subscriptions,
)

# if the ad was created by selfserve then we know
# whether or not there exists an ad for that keyword
# and can remove un-targeted keywords accordingly.
if live_promos_only:
live_srnames = all_live_promo_srnames()
keywords = live_srnames.intersection(keywords)

if (not isinstance(site,FakeSubreddit) and
site._downs > g.live_config["ads_popularity_threshold"]):
keywords.add("s.popular")
Expand Down

0 comments on commit 21dd731

Please sign in to comment.