mirror of
https://github.com/strapi/strapi.git
synced 2025-11-13 16:52:18 +00:00
rename findOneWithUsersCount
Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
parent
77eec454ff
commit
9cfc34e19f
@ -5,7 +5,7 @@ const { validateRoleUpdateInput } = require('../validation/role');
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
async findOne(ctx) {
|
async findOne(ctx) {
|
||||||
const { id } = ctx.params;
|
const { id } = ctx.params;
|
||||||
const role = await strapi.admin.services.role.findOneWithUsersCounts({ id });
|
const role = await strapi.admin.services.role.findOneWithUsersCount({ id });
|
||||||
|
|
||||||
if (!role) {
|
if (!role) {
|
||||||
return ctx.notFound('role.notFound');
|
return ctx.notFound('role.notFound');
|
||||||
|
|||||||
@ -54,7 +54,7 @@ describe('Role', () => {
|
|||||||
query: () => ({ findOne: dbFindOne, count: dbCount }),
|
query: () => ({ findOne: dbFindOne, count: dbCount }),
|
||||||
};
|
};
|
||||||
|
|
||||||
const foundRole = await roleService.findOneWithUsersCounts({ id: role.id });
|
const foundRole = await roleService.findOneWithUsersCount({ id: role.id });
|
||||||
|
|
||||||
expect(dbFindOne).toHaveBeenCalledWith({ id: role.id }, []);
|
expect(dbFindOne).toHaveBeenCalledWith({ id: role.id }, []);
|
||||||
expect(dbCount).toHaveBeenCalledWith({ 'roles.id': role.id });
|
expect(dbCount).toHaveBeenCalledWith({ 'roles.id': role.id });
|
||||||
|
|||||||
@ -36,7 +36,7 @@ const findOne = (params = {}, populate = []) => {
|
|||||||
* @param params query params to find the role
|
* @param params query params to find the role
|
||||||
* @returns {Promise<role>}
|
* @returns {Promise<role>}
|
||||||
*/
|
*/
|
||||||
const findOneWithUsersCounts = async (params = {}, populate = []) => {
|
const findOneWithUsersCount = async (params = {}, populate = []) => {
|
||||||
const role = await strapi.query('role', 'admin').findOne(params, populate);
|
const role = await strapi.query('role', 'admin').findOne(params, populate);
|
||||||
|
|
||||||
if (role) {
|
if (role) {
|
||||||
@ -130,7 +130,7 @@ const deleteByIds = async (ids = []) => {
|
|||||||
|
|
||||||
/** Count the number of users for some roles
|
/** Count the number of users for some roles
|
||||||
* @param rolesIds
|
* @param rolesIds
|
||||||
* @returns {Promise<array>}
|
* @returns {Promise<integer>}
|
||||||
*/
|
*/
|
||||||
const getUsersCount = async roleId => {
|
const getUsersCount = async roleId => {
|
||||||
return strapi.query('user', 'admin').count({ 'roles.id': roleId });
|
return strapi.query('user', 'admin').count({ 'roles.id': roleId });
|
||||||
@ -140,7 +140,7 @@ module.exports = {
|
|||||||
sanitizeRole,
|
sanitizeRole,
|
||||||
create,
|
create,
|
||||||
findOne,
|
findOne,
|
||||||
findOneWithUsersCounts,
|
findOneWithUsersCount,
|
||||||
find,
|
find,
|
||||||
findAllWithUsersCount,
|
findAllWithUsersCount,
|
||||||
update,
|
update,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user