PromotedLinkTraffic: better handle campaigns that end early.

This commit is contained in:
Brian Simpson
2014-01-12 04:55:05 -05:00
parent 41fdbce89b
commit ca0e53f613

View File

@@ -638,6 +638,12 @@ class PromotedLinkTraffic(Templated):
"""Shorten range for display and add next/prev buttons."""
start, end = promote.get_traffic_dates(thing)
# Check date of latest traffic (campaigns can end early).
history = get_promo_traffic(thing, start, end)
end = max(date for date, data in history)
end = end.replace(tzinfo=g.tz) # get_promo_traffic returns tz naive
# datetimes but is actually g.tz
if self.period:
display_start = self.after
display_end = self.before