mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Updated staff count query to include invites
refs: https://github.com/TryGhost/Team/issues/510 - we need to make sure we take into account any invites that could be accepted at any time - this counts all invites for non-contributor roles as well as all users who aren't contributors - this should stop there being loop holes to inviting staff users
This commit is contained in:
parent
cf21244e31
commit
75e857b76b
1 changed files with 8 additions and 3 deletions
|
@ -8,12 +8,17 @@ module.exports = {
|
|||
staff: {
|
||||
currentCountQuery: async (db) => {
|
||||
let result = await db.knex('users')
|
||||
.count('users.id', {as: 'count'})
|
||||
.select('users.id')
|
||||
.leftJoin('roles_users', 'users.id', 'roles_users.user_id')
|
||||
.leftJoin('roles', 'roles_users.role_id', 'roles.id')
|
||||
.whereNot('roles.name', 'Contributor').andWhereNot('users.status', 'inactive').first();
|
||||
.whereNot('roles.name', 'Contributor').andWhereNot('users.status', 'inactive').union([
|
||||
db.knex('invites')
|
||||
.select('invites.id')
|
||||
.leftJoin('roles', 'invites.role_id', 'roles.id')
|
||||
.whereNot('roles.name', 'Contributor')
|
||||
]);
|
||||
|
||||
return result.count;
|
||||
return result.length;
|
||||
}
|
||||
},
|
||||
custom_integrations: {
|
||||
|
|
Loading…
Add table
Reference in a new issue