diff mbox

[Branch,~linaro-validation/lava-dashboard/trunk] Rev 340: correctness and performance tweaks for filter attribute autocompletion

Message ID 20120906220211.10991.32131.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Michael-Doyle Hudson Sept. 6, 2012, 10:02 p.m. UTC
------------------------------------------------------------
revno: 340
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Fri 2012-09-07 10:01:28 +1200
message:
  correctness and performance tweaks for filter attribute autocompletion
modified:
  dashboard_app/views.py


--
lp:lava-dashboard
https://code.launchpad.net/~linaro-validation/lava-dashboard/trunk

You are subscribed to branch lp:lava-dashboard.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dashboard/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'dashboard_app/views.py'
--- dashboard_app/views.py	2012-09-03 00:16:21 +0000
+++ dashboard_app/views.py	2012-09-06 22:01:28 +0000
@@ -26,6 +26,7 @@ 
 from django.conf import settings
 from django.contrib.admin.widgets import FilteredSelectMultiple
 from django.contrib.auth.decorators import login_required
+from django.contrib.contenttypes.models import ContentType
 from django.contrib.sites.models import Site
 from django.core.exceptions import PermissionDenied, ValidationError
 from django.core.urlresolvers import reverse
@@ -859,8 +860,10 @@ 
 
 def filter_attr_name_completion_json(request):
     term = request.GET['term']
+    content_type_id = ContentType.objects.get_for_model(TestRun).id
     result = NamedAttribute.objects.filter(
-        name__startswith=term).distinct('name').order_by('name').values_list('name', flat=True)
+        name__startswith=term, content_type_id=content_type_id
+        ).distinct().order_by('name').values_list('name', flat=True)
     return HttpResponse(
         json.dumps(list(result)),
         mimetype='application/json')
@@ -869,9 +872,10 @@ 
 def filter_attr_value_completion_json(request):
     name = request.GET['name']
     term = request.GET['term']
+    content_type_id = ContentType.objects.get_for_model(TestRun).id
     result = NamedAttribute.objects.filter(
-        name=name,
-        value__startswith=term).distinct('value').order_by('value').values_list('value', flat=True)
+        name=name, content_type_id=content_type_id, value__startswith=term
+        ).distinct().order_by('value').values_list('value', flat=True)
     return HttpResponse(
         json.dumps(list(result)),
         mimetype='application/json')