mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 11:20:39 -03:30
Fix for active hosts count when running unit tests with SQLite.
This commit is contained in:
parent
fcf7398ec6
commit
1faa2be3b4
@ -13,8 +13,10 @@ class HostManager(models.Manager):
|
||||
|
||||
def active_count(self):
|
||||
"""Return count of active, unique hosts for licensing."""
|
||||
return self.filter(active=True, inventory__active=True).distinct('name').count()
|
||||
|
||||
try:
|
||||
return self.filter(active=True, inventory__active=True).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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user