[RFC,4/4] REST: Only fetch required fields event filtering

Message ID 20180110004024.5551-5-stephen@that.guru
State Under Review
Headers show
  • Add 'Event.payload' field
Related show

Commit Message

Stephen Finucane Jan. 10, 2018, 12:40 a.m.
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 <stephen@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')