The filter widget is pretty dumb, containing a full list of every patch
in the system. We will want to rework this in the future, but for now
just minimize the amount of data we're pulling in.

Signed-off-by: Stephen Finucane <step...@that.guru>
---
 patchwork/api/filters.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/patchwork/api/filters.py b/patchwork/api/filters.py
index d207b2b6..ab6d6f55 100644
--- a/patchwork/api/filters.py
+++ b/patchwork/api/filters.py
@@ -174,6 +174,13 @@ class CheckFilter(TimestampMixin, FilterSet):
 
 class EventFilter(ProjectMixin, TimestampMixin, FilterSet):
 
+    patch = ModelChoiceFilter(queryset=Patch.objects.only('pk', 'name'))
+    series = ModelChoiceFilter(queryset=Series.objects.only('pk', 'name'))
+    cover = ModelChoiceFilter(queryset=CoverLetter.objects.only('pk', 'name'))
+
+    def filter_patch(self, queryset, name, value):
+        return queryset.only('pk', 'name')
+
     class Meta:
         model = Event
         fields = ('project', 'category', 'series', 'patch', 'cover')
-- 
2.14.3

_______________________________________________
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork

Reply via email to