Return the correct server & subuser counts for user listing; closes #2469

This commit is contained in:
Dane Everitt 2020-10-10 18:06:42 -07:00
parent 1f7fe093ae
commit 7b0f998f0b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 61 additions and 2 deletions

View file

@ -86,8 +86,8 @@ class UserController extends Controller
{
$users = QueryBuilder::for(
User::query()->select('users.*')
->selectRaw('COUNT(subusers.id) as subuser_of_count')
->selectRaw('COUNT(servers.id) as servers_count')
->selectRaw('COUNT(DISTINCT(subusers.id)) as subuser_of_count')
->selectRaw('COUNT(DISTINCT(servers.id)) as servers_count')
->leftJoin('subusers', 'subusers.user_id', '=', 'users.id')
->leftJoin('servers', 'servers.owner_id', '=', 'users.id')
->groupBy('users.id')