# HG changeset patch # User ymh # Date 1466550238 -7200 # Node ID d427a6db1902f858fa95aac1e8004a0b326bb17c # Parent 3051b847c124a167dc3fe2c23f8e27ffb6f580be small optimization on renkan loading: prefecht current revision diff -r 3051b847c124 -r d427a6db1902 server/python/django2/renkanmanager/api/views.py --- a/server/python/django2/renkanmanager/api/views.py Tue Jun 21 17:53:06 2016 +0200 +++ b/server/python/django2/renkanmanager/api/views.py Wed Jun 22 01:03:58 2016 +0200 @@ -34,7 +34,7 @@ View for listing renkans or posting new renkan """ - queryset = Renkan.objects + queryset = Renkan.objects.select_related('current_revision') def get(self, request, workspace_guid='', format=None): if workspace_guid == '': @@ -58,7 +58,7 @@ source_revision = None if source_renkan_guid is not None: try: - source_renkan=Renkan.objects.get(renkan_guid=source_renkan_guid) + source_renkan=Renkan.objects.select_related('current_revision').get(renkan_guid=source_renkan_guid) except Renkan.DoesNotExist: return Response({'detail': 'Source renkan %s does not exist'%source_renkan_guid}, status=status.HTTP_404_NOT_FOUND) source_revision = source_renkan.current_revision @@ -99,7 +99,7 @@ View for retrieving, updating or deleting a single renkan """ lookup_field = "renkan_guid" - queryset = Renkan.objects + queryset = Renkan.objects.select_related('current_revision') def get_object(self, renkan_guid): try: diff -r 3051b847c124 -r d427a6db1902 server/python/django2/renkanmanager/serializers.py --- a/server/python/django2/renkanmanager/serializers.py Tue Jun 21 17:53:06 2016 +0200 +++ b/server/python/django2/renkanmanager/serializers.py Wed Jun 22 01:03:58 2016 +0200 @@ -84,7 +84,7 @@ raise serializers.ValidationError(str(ve.args[0])) # FORCE Renkan reload. # TODO: How to avoid the reload ??? - return Renkan.objects.get(id=renkan.id) + return Renkan.objects.select_related('current_revision').get(id=renkan.id) def validate_workspace_id(self, value): if self.instance is not None: