Commit 9b042b14 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

API: Look also for cover letter when looking up a msg-id

The only difference in comparison to patch is a lack of patch_id in the
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <>
parent 70435e50
......@@ -510,6 +510,15 @@ class MsgidsLookupTest(APITestBase):
self.assertEquals(len(response), 2)
def testCoverLetterLookup(self):
response = self.get_json(self.msgid_url.format(self.root_msgid))
self.assertEquals(len(response), 1)
self.assertTrue('patch_id' not in response[0].keys())
self.assertEquals(response[0]['project_id'], self.series.project_id)
self.assertEquals(response[0]['revision_ids'], [self.revision.version])
class TestResultTest(APITestBase):
rev_url = '/series/%(series_id)s/revisions/%(version)s/test-results/'
......@@ -24,6 +24,7 @@ from django.conf import settings
from django.core import mail
from django.db.models import Q
from django.http import HttpResponse, JsonResponse
from itertools import groupby
from patchwork.tasks import send_reviewer_notification
from patchwork.models import (Project, Series, SeriesRevision, Patch, EventLog,
State, Test, TestResult, TestState, Person,
......@@ -548,6 +549,11 @@ class PatchViewSet(mixins.ListModelMixin,
return patch_mbox(request, pk)
def __grouping(iterable, key):
sorted_iterable = sorted(iterable, key=key)
return groupby(sorted_iterable, key)
def msgid(request, msgid):
output = []
......@@ -566,6 +572,15 @@ def msgid(request, msgid):
output += [desc]
revisions = SeriesRevision.objects.filter(root_msgid=msgid,
for (series_id, rev_grp) in __grouping(revisions, lambda x: x.series_id):
rev_grp = list(rev_grp)
desc = {'project_id': rev_grp[0].series.project_id,
'series_id': series_id,
'revision_ids': [rev.version for rev in rev_grp]}
output += [desc]
return JsonResponse(output, safe=False)
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