rename findOneWithUsersCount

Signed-off-by: Pierre Noël <petersg83@gmail.com>
This commit is contained in:
Pierre Noël 2020-06-01 09:56:53 +02:00 committed by Alexandre Bodin
parent 77eec454ff
commit 9cfc34e19f
3 changed files with 5 additions and 5 deletions

View File

@ -5,7 +5,7 @@ const { validateRoleUpdateInput } = require('../validation/role');
module.exports = {
async findOne(ctx) {
const { id } = ctx.params;
const role = await strapi.admin.services.role.findOneWithUsersCounts({ id });
const role = await strapi.admin.services.role.findOneWithUsersCount({ id });
if (!role) {
return ctx.notFound('role.notFound');

View File

@ -54,7 +54,7 @@ describe('Role', () => {
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(dbCount).toHaveBeenCalledWith({ 'roles.id': role.id });

View File

@ -36,7 +36,7 @@ const findOne = (params = {}, populate = []) => {
* @param params query params to find the role
* @returns {Promise<role>}
*/
const findOneWithUsersCounts = async (params = {}, populate = []) => {
const findOneWithUsersCount = async (params = {}, populate = []) => {
const role = await strapi.query('role', 'admin').findOne(params, populate);
if (role) {
@ -130,7 +130,7 @@ const deleteByIds = async (ids = []) => {
/** Count the number of users for some roles
* @param rolesIds
* @returns {Promise<array>}
* @returns {Promise<integer>}
*/
const getUsersCount = async roleId => {
return strapi.query('user', 'admin').count({ 'roles.id': roleId });
@ -140,7 +140,7 @@ module.exports = {
sanitizeRole,
create,
findOne,
findOneWithUsersCounts,
findOneWithUsersCount,
find,
findAllWithUsersCount,
update,