mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-02-07 13:14:54 -05:00
Let promote.get_total_run figure out dates for get_traffic_dates.
This commit is contained in:
@@ -458,19 +458,7 @@ def get_traffic_dates(thing):
|
||||
"""Retrieve the start and end of a Promoted Link or PromoCampaign."""
|
||||
now = datetime.datetime.now(g.tz).replace(minute=0, second=0,
|
||||
microsecond=0)
|
||||
|
||||
if isinstance(thing, Link):
|
||||
start, end = promote.get_total_run(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 UTC-5
|
||||
promo_tz = pytz.timezone("US/Eastern")
|
||||
start = (thing.start_date.replace(tzinfo=promo_tz)
|
||||
.astimezone(pytz.utc))
|
||||
end = (thing.end_date.replace(tzinfo=promo_tz)
|
||||
.astimezone(pytz.utc))
|
||||
|
||||
start, end = promote.get_total_run(thing)
|
||||
end = min(now, end)
|
||||
return start, end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user