Minor fixes based on comments.

This commit is contained in:
Chris Church
2016-02-03 13:18:49 -05:00
parent b08a2d1d88
commit ab8e37eeaa
5 changed files with 4 additions and 18 deletions

View File

@@ -12,11 +12,10 @@ class HostManager(models.Manager):
def active_count(self):
"""Return count of active, unique hosts for licensing."""
#try:
# return self.filter(active=True, inventory__active=True).distinct('name').count()
#except NotImplementedError: # For unit tests only, SQLite doesn't support distinct('name')
# FIXME-CC
return len(set(self.filter(active=True, inventory__active=True).values_list('name', flat=True)))
try:
return self.filter(active=True, inventory__active=True).order_by('name').distinct('name').count()
except NotImplementedError: # For unit tests only, SQLite doesn't support distinct('name')
return len(set(self.filter(active=True, inventory__active=True).values_list('name', flat=True)))
class InstanceManager(models.Manager):
"""A custom manager class for the Instance model.