Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't load everything into memory. That's bad.

  • Loading branch information...
commit f18bc146c6acfb0bd88cae29eea61299011c6d4f 1 parent 602a29b
@mythmon authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 apps/kpi/cron.py
View
10 apps/kpi/cron.py
@@ -244,11 +244,11 @@ def update_aoa_contributors_metric(day=None):
start = latest_metric.end + timedelta(days=1)
else:
# Start updating 30 days after the first reply we have.
- replies = Reply.objects.order_by('created')
- if replies:
- start = replies[0].created.date() + timedelta(days=30)
- else:
- # If there are no replies, bail.
+ try:
+ first_reply = Repy.objects.order_by('created')[0]
+ start = first_reply.created.date() + timedelta(days=30)
+ except IndexError:
+ # If there is no data, there is nothing to do here.
return
# Update until yesterday.
Please sign in to comment.
Something went wrong with that request. Please try again.