mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 00:07:57 -05:00
Take PromoCampaigns as inputs in promote.get_total_run.
This commit is contained in:
@@ -464,7 +464,7 @@ def get_traffic_dates(thing):
|
||||
start, end = start.replace(tzinfo=g.tz), end.replace(tzinfo=g.tz)
|
||||
elif isinstance(thing, PromoCampaign):
|
||||
# PromoCampaigns store their dates as UTC, promote changes occur
|
||||
# at 12 AM EST
|
||||
# at UTC-5
|
||||
promo_tz = pytz.timezone("US/Eastern")
|
||||
start = (thing.start_date.replace(tzinfo=promo_tz)
|
||||
.astimezone(pytz.utc))
|
||||
|
||||
@@ -842,15 +842,18 @@ def sample_promoted_links(user, site, n=10):
|
||||
return random.sample(promo_tuples, n)
|
||||
|
||||
|
||||
def get_total_run(link):
|
||||
"""Return the total time span this promotion has run for.
|
||||
def get_total_run(thing):
|
||||
"""Return the total time span this link or campaign will run.
|
||||
|
||||
Starts at the start date of the earliest campaign and goes to the end date
|
||||
of the latest campaign.
|
||||
|
||||
"""
|
||||
|
||||
campaigns = PromoCampaign._by_link(link._id)
|
||||
if isinstance(thing, Link):
|
||||
campaigns = PromoCampaign._by_link(thing._id)
|
||||
elif isinstance(thing, PromoCampaign):
|
||||
campaigns = [thing]
|
||||
|
||||
earliest = None
|
||||
latest = None
|
||||
|
||||
Reference in New Issue
Block a user