Ghost/ghost/limit-service/lib/config.js
Naz 0f049fbb94 Improved query formatting
refs https://github.com/TryGhost/Team/issues/599

- Oneliners with lots of chained commands are hardly readable on small screens
2021-04-07 18:13:10 +12:00

36 lines
1.2 KiB
JavaScript

module.exports = {
members: {
currentCountQuery: async (db) => {
let result = await db.knex('members').count('id', {as: 'count'}).first();
return result.count;
}
},
staff: {
currentCountQuery: async (db) => {
let result = await db.knex('users')
.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').union([
db.knex('invites')
.select('invites.id')
.leftJoin('roles', 'invites.role_id', 'roles.id')
.whereNot('roles.name', 'Contributor')
]);
return result.length;
}
},
customIntegrations: {
currentCountQuery: async (db) => {
let result = await db.knex('integrations')
.count('id', {as: 'count'})
.whereNotIn('type', ['internal', 'builtin'])
.first();
return result.count;
}
},
customThemes: {}
};