mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-29 00:38:11 -05:00
Move get_traffic_dates from trafficpages to promote.
This commit is contained in:
committed by
Brian Simpson
parent
776755b9df
commit
4b76634aa4
@@ -479,15 +479,6 @@ def _is_promo_preliminary(end_date):
|
||||
return end_date + datetime.timedelta(days=1) > now
|
||||
|
||||
|
||||
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)
|
||||
start, end = promote.get_total_run(thing)
|
||||
end = min(now, end)
|
||||
return start, end
|
||||
|
||||
|
||||
def get_promo_traffic(thing, start, end):
|
||||
"""Get traffic for a Promoted Link or PromoCampaign"""
|
||||
if isinstance(thing, Link):
|
||||
@@ -511,7 +502,7 @@ def get_promo_traffic(thing, start, end):
|
||||
|
||||
def get_billable_traffic(campaign):
|
||||
"""Get traffic for dates when PromoCampaign is active."""
|
||||
start, end = get_traffic_dates(campaign)
|
||||
start, end = promote.get_traffic_dates(campaign)
|
||||
return get_promo_traffic(campaign, start, end)
|
||||
|
||||
|
||||
@@ -638,7 +629,7 @@ class PromotedLinkTraffic(Templated):
|
||||
|
||||
def check_dates(self, thing):
|
||||
"""Shorten range for display and add next/prev buttons."""
|
||||
start, end = get_traffic_dates(thing)
|
||||
start, end = promote.get_traffic_dates(thing)
|
||||
|
||||
if self.period:
|
||||
display_start = self.after
|
||||
@@ -721,7 +712,7 @@ class PromotedLinkTraffic(Templated):
|
||||
import csv
|
||||
import cStringIO
|
||||
|
||||
start, end = get_traffic_dates(thing)
|
||||
start, end = promote.get_traffic_dates(thing)
|
||||
history = cls.get_hourly_traffic(thing, start, end)
|
||||
|
||||
out = cStringIO.StringIO()
|
||||
|
||||
@@ -826,6 +826,14 @@ def get_total_run(thing):
|
||||
return earliest, latest
|
||||
|
||||
|
||||
def get_traffic_dates(thing):
|
||||
"""Retrieve the start and end of a Promoted Link or PromoCampaign."""
|
||||
now = datetime.now(g.tz).replace(minute=0, second=0, microsecond=0)
|
||||
start, end = get_total_run(thing)
|
||||
end = min(now, end)
|
||||
return start, end
|
||||
|
||||
|
||||
def Run(offset=0, verbose=True):
|
||||
"""reddit-job-update_promos: Intended to be run hourly to pull in
|
||||
scheduled changes to ads
|
||||
|
||||
Reference in New Issue
Block a user