missing when index. Where clause on latest_raw query

This commit is contained in:
Sandy Walsh 2012-12-05 16:25:09 -06:00
parent af7901dddf
commit 2fb3a5b482
2 changed files with 5 additions and 2 deletions

@ -38,7 +38,8 @@ class RawData(models.Model):
blank=True, db_index=True)
old_task = models.CharField(max_length=30, null=True,
blank=True, db_index=True)
when = models.DecimalField(max_digits=20, decimal_places=6)
when = models.DecimalField(max_digits=20, decimal_places=6,
db_index=True)
publisher = models.CharField(max_length=100, null=True,
blank=True, db_index=True)
event = models.CharField(max_length=50, null=True,

@ -314,7 +314,9 @@ def latest_raw(request, deployment_id):
"""This is the 2sec ticker that updates the Recent Activity box."""
deployment_id = int(deployment_id)
c = _default_context(request, deployment_id)
query = models.RawData.objects.select_related()
then = datetime.datetime.utcnow() - datetime.timedelta(hours=1)
thend = dt.dt_to_decimal(then)
query = models.RawData.objects.select_related().filter(when__gt=thend)
if deployment_id > 0:
query = query.filter(deployment=deployment_id)
rows = query.order_by('-when')[:20]