[PATCH 2/5] models: Remove Bundle.n_patches

Stephen Finucane stephen at that.guru
Tue Oct 11 09:44:47 AEDT 2016


It doesn't really do much for us. Less LOC = win.

Signed-off-by: Stephen Finucane <stephen at that.guru>
---
 patchwork/models.py                        | 3 ---
 patchwork/templates/patchwork/bundles.html | 2 +-
 patchwork/views/xmlrpc.py                  | 2 +-
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/patchwork/models.py b/patchwork/models.py
index 2a98eff..3c554af 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -570,9 +570,6 @@ class Bundle(models.Model):
     patches = models.ManyToManyField(Patch, through='BundlePatch')
     public = models.BooleanField(default=False)
 
-    def n_patches(self):
-        return self.patches.all().count()
-
     def ordered_patches(self):
         return self.patches.order_by('bundlepatch__order')
 
diff --git a/patchwork/templates/patchwork/bundles.html b/patchwork/templates/patchwork/bundles.html
index 2eebd26..45bdec5 100644
--- a/patchwork/templates/patchwork/bundles.html
+++ b/patchwork/templates/patchwork/bundles.html
@@ -27,7 +27,7 @@
     <a href="{{ bundle.public_url }}">{{ bundle.public_url }}</a>
    {% endif %}
   </td>
-  <td style="text-align: right">{{ bundle.n_patches }}</td>
+  <td style="text-align: right">{{ bundle.patches.count }}</td>
   <td style="text-align: center;"><a
    href="{% url 'bundle-mbox' username=bundle.owner.username bundlename=bundle.name %}"
    ><img src="{% static "images/16-em-down.png" %}" width="16" height="16" alt="download"
diff --git a/patchwork/views/xmlrpc.py b/patchwork/views/xmlrpc.py
index cfb80d3..30829e7 100644
--- a/patchwork/views/xmlrpc.py
+++ b/patchwork/views/xmlrpc.py
@@ -311,7 +311,7 @@ def bundle_to_dict(obj):
     return {
         'id': obj.id,
         'name': obj.name,
-        'n_patches': obj.n_patches(),
+        'n_patches': obj.patches.count(),
         'public_url': obj.public_url(),
     }
 
-- 
2.7.4



More information about the Patchwork mailing list