[PATCH 4/4] REST: Add submission relations

Daniel Axtens dja at axtens.net
Mon Jan 27 00:15:34 AEDT 2020


I've made good progress with this, things work etc, I'm just wrestling
with SQL queries. One thing I noticed is that the current /api/patches/
list seems to go out to the database for the project linkname for every
patch:

...
/opt/pyenv/versions/3.8.1/lib/python3.8/site-packages/rest_framework/serializers.py in to_representation(674)
  return [
/opt/pyenv/versions/3.8.1/lib/python3.8/site-packages/rest_framework/serializers.py in <listcomp>(675)
  self.child.to_representation(item) for item in iterable
/home/patchwork/patchwork/patchwork/api/patch.py in to_representation(110)
  data = super(PatchListSerializer, self).to_representation(instance)
/home/patchwork/patchwork/patchwork/api/base.py in to_representation(90)
  data = super(BaseHyperlinkedModelSerializer, self).to_representation(
/opt/pyenv/versions/3.8.1/lib/python3.8/site-packages/rest_framework/serializers.py in to_representation(526)
  ret[field.field_name] = field.to_representation(attribute)
/home/patchwork/patchwork/patchwork/api/embedded.py in to_representation(57)
  return self._Serializer(context=self.context).to_representation(data)
/home/patchwork/patchwork/patchwork/api/base.py in to_representation(90)
  data = super(BaseHyperlinkedModelSerializer, self).to_representation(
/opt/pyenv/versions/3.8.1/lib/python3.8/site-packages/rest_framework/serializers.py in to_representation(526)
  ret[field.field_name] = field.to_representation(attribute)
/opt/pyenv/versions/3.8.1/lib/python3.8/site-packages/rest_framework/fields.py in to_representation(1873)
  return method(value)
/home/patchwork/patchwork/patchwork/api/embedded.py in get_web_url(81)
  return request.build_absolute_uri(instance.get_absolute_url())
/home/patchwork/patchwork/patchwork/models.py in get_absolute_url(767)
  kwargs={'project_id': self.project.linkname}) + (
  
I see about 22 of these, perfectly identical, on the existing code - and
the number goes up when I include the new code which displays more
embedded patches.

Thoughts?

Regards,
Daniel

Stephen Finucane <stephen at that.guru> writes:

> On Sat, 2020-01-25 at 00:20 +1100, Daniel Axtens wrote:
>> I've spent some time tonight bashing this out, based on Stephen's API
>> design. I have got display to work, just working on writing now.
>> 
>> Stephen, would you be able to write the API spec if I can send an
>> otherwise working implementation? I think the ramp-up time for me on
>> that might be a big unnecessary delay...
>
> Sure thing.
>
> Stephen
>
>> Kind regards,
>> Daniel


More information about the Patchwork mailing list