]> git.ozlabs.org Git - patchwork/commitdiff
xmlrpc: do slice before patch_to_dict
authorJeremy Kerr <jk@ozlabs.org>
Mon, 18 Jul 2011 13:46:08 +0000 (21:46 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Mon, 18 Jul 2011 13:46:08 +0000 (21:46 +0800)
Currently, we map patch_to_dict before we slice the results (to only
return max_count patches). This means that we hacve to retrieve all
patches, then throw away most of the results of the map.

This change does the slice on the patches before the map, letting django
do a LIMIT-ed query instead.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
apps/patchwork/views/xmlrpc.py

index bb9ebe15d82a9df37176d6fa42167db7efdb7073..283eb34be865fd129c5b1ddcd09328f3fa98e225 100644 (file)
@@ -328,7 +328,7 @@ def patch_list(filter={}):
         patches = Patch.objects.filter(**dfilter)
 
         if max_count > 0:
-            return map(patch_to_dict, patches)[:max_count]
+            return map(patch_to_dict, patches[:max_count])
         else:
             return map(patch_to_dict, patches)