mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 10:55:37 +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 = {
|
||||
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');
|
||||
|
||||
@ -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 });
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user