diff --git a/lib/StorageStatistics.php b/lib/StorageStatistics.php index b53b66d9..0e14a759 100644 --- a/lib/StorageStatistics.php +++ b/lib/StorageStatistics.php @@ -13,6 +13,7 @@ use OCP\Files\IRootFolder; use OCP\IAppConfig; use OCP\IDBConnection; +use OCP\IUserManager; class StorageStatistics { @@ -20,12 +21,14 @@ public function __construct( private IDBConnection $connection, private IRootFolder $rootFolder, private IAppConfig $appConfig, + private IUserManager $userManager, ) { } public function getStorageStatistics(): array { return [ 'num_users' => $this->countUserEntries(), + 'num_disabled_users' => $this->countDisabledUserEntries(), 'num_files' => $this->getCountOf('filecache'), 'num_storages' => $this->getCountOf('storages'), 'num_storages_local' => $this->countStorages('local'), @@ -40,14 +43,11 @@ public function getStorageStatistics(): array { * count number of users */ protected function countUserEntries(): int { - $query = $this->connection->getQueryBuilder(); - $query->selectAlias($query->createFunction('COUNT(*)'), 'num_entries') - ->from('preferences') - ->where($query->expr()->eq('configkey', $query->createNamedParameter('lastLogin'))); - $result = $query->executeQuery(); - $row = $result->fetch(); - $result->closeCursor(); - return (int)$row['num_entries']; + return $this->userManager->countSeenUsers(); + } + + protected function countDisabledUserEntries(): int { + return $this->userManager->countDisabledUsers(); } protected function getCountOf(string $table): int {