mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 01:46:07 +00:00
solve some more testcases, but still problems with searchAdminUser and
some more...
This commit is contained in:
parent
9830afb91c
commit
6189857ed4
@ -1404,7 +1404,7 @@ describe('UserResolver', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('finds peter@lustig.de', async () => {
|
||||
it.only('finds peter@lustig.de', async () => {
|
||||
await expect(mutate({ mutation: searchAdminUsers })).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
data: {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||
import { getConnection, getCustomRepository, IsNull, Not } from '@dbTools/typeorm'
|
||||
import { getConnection, getCustomRepository, In, IsNull, Not } from '@dbTools/typeorm'
|
||||
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
|
||||
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
|
||||
import { User as DbUser } from '@entity/User'
|
||||
@ -76,6 +76,7 @@ import { FULL_CREATION_AVAILABLE } from './const/const'
|
||||
import { getUserCreations } from './util/creations'
|
||||
import { findUserByIdentifier } from './util/findUserByIdentifier'
|
||||
import { validateAlias } from './util/validateAlias'
|
||||
import { ArrayMinSize } from 'class-validator'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-commonjs
|
||||
const random = require('random-bigint')
|
||||
@ -616,10 +617,12 @@ export class UserResolver {
|
||||
{ currentPage = 1, pageSize = 25, order = Order.DESC }: Paginated,
|
||||
): Promise<SearchAdminUsersResult> {
|
||||
const userRepository = getCustomRepository(UserRepository)
|
||||
console.log('test')
|
||||
|
||||
const [users, count] = await userRepository.findAndCount({
|
||||
relations: ['userRoles'],
|
||||
where: {
|
||||
userRoles: Not(IsNull()),
|
||||
userRoles: { role: In(['admin', 'moderator']) },
|
||||
},
|
||||
order: {
|
||||
createdAt: order,
|
||||
@ -627,7 +630,7 @@ export class UserResolver {
|
||||
skip: (currentPage - 1) * pageSize,
|
||||
take: pageSize,
|
||||
})
|
||||
|
||||
console.log('users=', users)
|
||||
return {
|
||||
userCount: count,
|
||||
userList: users.map((user) => {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { Brackets, EntityRepository, IsNull, Not, Repository } from '@dbTools/typeorm'
|
||||
import { User as DbUser } from '@entity/User'
|
||||
|
||||
import { ROLE_NAMES } from '@/auth/ROLES'
|
||||
import { SearchUsersFilters } from '@/graphql/arg/SearchUsersFilters'
|
||||
|
||||
@EntityRepository(DbUser)
|
||||
@ -12,11 +13,21 @@ export class UserRepository extends Repository<DbUser> {
|
||||
currentPage: number,
|
||||
pageSize: number,
|
||||
): Promise<[DbUser[], number]> {
|
||||
const selectAttr = [
|
||||
'user.id AS user_id',
|
||||
'user.email_id AS user_email_id',
|
||||
'user.first_name AS user_first_name',
|
||||
'user.last_name AS user_last_name',
|
||||
'user.deleted_at AS user_deleted_at',
|
||||
'count',
|
||||
]
|
||||
const query = this.createQueryBuilder('user')
|
||||
.select(select)
|
||||
.select(selectAttr)
|
||||
.withDeleted()
|
||||
.leftJoinAndSelect('user.emailContact', 'emailContact')
|
||||
.leftJoinAndSelect('user.userRoles', 'userRoles')
|
||||
.leftJoinAndSelect('user.userRoles', 'userRoles', 'userRoles.role in :rolenames', {
|
||||
rolenames: [ROLE_NAMES.ROLE_NAME_ADMIN, ROLE_NAMES.ROLE_NAME_MODERATOR],
|
||||
})
|
||||
.where(
|
||||
new Brackets((qb) => {
|
||||
qb.where(
|
||||
@ -45,7 +56,7 @@ export class UserRepository extends Repository<DbUser> {
|
||||
query.andWhere({ deletedAt: filters.byDeleted ? Not(IsNull()) : IsNull() })
|
||||
}
|
||||
}
|
||||
|
||||
console.log('query=', query.getQueryAndParameters())
|
||||
return query
|
||||
.take(pageSize)
|
||||
.skip((currentPage - 1) * pageSize)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user