summaryrefslogtreecommitdiff
path: root/main/models.py
diff options
context:
space:
mode:
authorDusty Phillips <buchuki@gmail.com>2008-10-07 11:17:48 -0400
committerDusty Phillips <buchuki@gmail.com>2008-10-07 11:17:48 -0400
commit53a4f63094e903f89bed84b90c5c69af1f7e5d2f (patch)
tree8ae99173e11b20764aab62276726743a525cb9b8 /main/models.py
parentfd26d34abfa02baf826ec6836b56abe0a5149dca (diff)
optimize get_flag_stats
Diffstat (limited to 'main/models.py')
-rw-r--r--main/models.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/main/models.py b/main/models.py
index f8f86995..e7566c35 100644
--- a/main/models.py
+++ b/main/models.py
@@ -52,19 +52,18 @@ class PackageManager(models.Manager):
def get_flag_stats(self):
results = []
# first the orphans
- noflag = self.filter(maintainer=0).count()
- flagged = self.filter(maintainer=0).filter(
+ noflag = self.filter(maintainer=0)
+ flagged = noflag.filter(
needupdate=True).exclude(
- repo__name__iexact='testing').count()
+ repo__name__iexact='testing')
results.append(
- (User(id=0,first_name='Orphans'), noflag, flagged))
+ (User(id=0,first_name='Orphans'), noflag.count(), flagged.count()))
# now the rest
for maint in User.objects.all().order_by('first_name'):
- noflag = self.filter(maintainer=maint.id).count()
- flagged = self.filter(maintainer=maint.id).filter(
- needupdate=True).exclude(
- repo__name__iexact='testing').count()
- results.append((maint, noflag, flagged))
+ noflag = self.filter(maintainer=maint.id)
+ flagged = noflag.filter(needupdate=True).exclude(
+ repo__name__iexact='testing')
+ results.append((maint, noflag.count(), flagged.count()))
return results