Skip to content

Commit

Permalink
Fix traffic display for SR discovery promos
Browse files Browse the repository at this point in the history
The "Read from PromoCampaign things" change broke the code that causes the
traffic display to show the past month by default if a promoted link has
no campaigns.

This change fixes a bug where clicking on "traffic" on one of the subreddit
discovery spotlight links caused a 500 error.

See: 273c548
  • Loading branch information
shlurbee authored and bsimpson63 committed Jul 25, 2012
1 parent 2ec1e7e commit 69b6a32
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions r2/r2/lib/promote.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,12 +970,6 @@ def get_total_run(link):

campaigns = PromoCampaign._by_link(link._id)

# a manually launched promo (e.g., sr discovery) might not have campaigns.
if not campaigns:
latest = datetime.utcnow()
earliest = latest - timedelta(days=30) # last month
return earliest, latest

earliest = None
latest = None
for campaign in campaigns:
Expand All @@ -987,7 +981,12 @@ def get_total_run(link):

if not latest or campaign.end_date > latest:
latest = campaign.end_date


# a manually launched promo (e.g., sr discovery) might not have campaigns.
if not earliest or not latest:
latest = datetime.utcnow()
earliest = latest - timedelta(days=30) # last month

# ugh this stuff is a mess. they're stored as "UTC" but actually mean UTC-5.
earliest = earliest.replace(tzinfo=None) - timezone_offset
latest = latest.replace(tzinfo=None) - timezone_offset
Expand Down

0 comments on commit 69b6a32

Please sign in to comment.