Commit 372e3f71 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

api: Add 'until' filtering on EventLog

We have 'since' filtering already and this can be used with some
interesting CI workflows.
Signed-off-by: default avatarArkadiusz Hiler <>
parent 13dbdab1
......@@ -232,6 +232,9 @@ Events
be used in the next query with a ``since`` parameter to only
retrieve events that haven't been seen yet.
:query until: Retrieve only events older than a specific time. Format is
the same as ``event_time`` in response, an ISO 8601 date.
:query name: Filter the events by name. This field is a comma separated
list of events names.
......@@ -35,7 +35,7 @@ from patchwork.tests.test_user import TestUser
from patchwork.tests.utils import TestSeries, read_mail
from patchwork.models import (
Series, Patch, SeriesRevision, Test, TestResult, TestState, State,
Project, Person, EventLog
Project, Person, Event, EventLog
from patchwork.serializers import SeriesSerializer
......@@ -385,6 +385,32 @@ class EventTest(APITestBase):
params={'since': after})
self.assertEqual(events['count'], 0)
def testSince(self):
now =
event_type = Event.objects.all()[0]
e1_time = now - datetime.timedelta(minutes=1)
e2_time = now
# we need to use .update() to bypass auto_now on the event_time
e1 = EventLog(event=event_type, series=self.series)
e2 = EventLog(event=event_type, series=self.series)
events = self.get_json('/projects/%(project_id)s/events/',
params={'until': e1_time.isoformat()})
self.assertEqual(0, events['count'])
events = self.get_json('/projects/%(project_id)s/events/',
params={'until': e2_time.isoformat()})
def testRetestApiEndpointAsSubmitter(self):
submitter = self.series.submitter
submitter.user = self.user.user
......@@ -639,6 +639,8 @@ class EventFilter(django_filters.FilterSet):
since = django_filters.CharFilter(field_name='event_time',
until = django_filters.CharFilter(field_name='event_time',
name = django_filters.CharFilter(method='filter_name')
series = django_filters.NumberFilter()
patch = django_filters.NumberFilter()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment