diff --git a/src/users/services/userRegistry.service.spec.ts b/src/users/services/userRegistry.service.spec.ts index 0df3a840e63bbdc962004ba3b2c557a5b2361d64..87eafc904a07506cf9d1b86cadf1de3bd345e086 100644 --- a/src/users/services/userRegistry.service.spec.ts +++ b/src/users/services/userRegistry.service.spec.ts @@ -14,6 +14,8 @@ describe('userRegistryService', () => { let service: UserRegistryService; const mockUserRegistryModel = { find: jest.fn(() => mockUserRegistryModel), + where: jest.fn(() => mockUserRegistryModel), + equals: jest.fn(() => mockUserRegistryModel), populate: jest.fn(() => mockUserRegistryModel), sort: jest.fn(() => mockUserRegistryModel), select: jest.fn(() => mockUserRegistryModel), diff --git a/src/users/services/userRegistry.service.ts b/src/users/services/userRegistry.service.ts index 1a7f687b5404405f9107d4b60fc6a901b1e085a2..b24ce76631e17eb825e092d54c2cd452a59ad39e 100644 --- a/src/users/services/userRegistry.service.ts +++ b/src/users/services/userRegistry.service.ts @@ -24,6 +24,8 @@ export class UserRegistryService { public async findAllForIndexation(): Promise<IUserRegistry[]> { return this.userModel .find() + .where('emailVerified') + .equals(true) .select('name surname _id job employer ') .populate('job employer') .sort({ surname: 1 }) @@ -33,6 +35,8 @@ export class UserRegistryService { public async countAllUserRegistry(): Promise<number> { return this.userModel .find() + .where('emailVerified') + .equals(true) .populate('employer') .populate('job') .select('name surname employer job _id ') @@ -46,6 +50,8 @@ export class UserRegistryService { const count = await this.countAllUserRegistry(); const docs = await this.userModel .find() + .where('emailVerified') + .equals(true) .populate('employer') .populate('job') .select('name surname employer job _id ') @@ -67,9 +73,8 @@ export class UserRegistryService { employersNames.findIndex((n) => user.employer.name === n) > -1 ); } - if (employersList?.length) { - return users.filter((user) => employersNames.findIndex((n) => user.employer.name === n) > -1); + return users.filter((user) => employersNames.findIndex((n) => user.employer?.name === n) > -1); } if (jobList?.length) { return users.filter((user) => jobNames.findIndex((n) => user.job.name === n) > -1); @@ -108,6 +113,8 @@ export class UserRegistryService { }, ], }) + .where('emailVerified') + .equals(true) .select('name surname employer job _id ') .populate('employer job') .sort({ surname: 1 }) diff --git a/src/users/services/users.service.ts b/src/users/services/users.service.ts index 19c9d58b63c09a3e9eea3cf41f384c44b0b913fa..9d3df36e23e98b6cbbf570633210ac199677a531 100644 --- a/src/users/services/users.service.ts +++ b/src/users/services/users.service.ts @@ -18,8 +18,8 @@ import { JobDocument } from '../schemas/job.schema'; import { PersonalOfferDocument } from '../../personal-offers/schemas/personal-offer.schema'; import { UpdateDetailsDto } from '../dto/update-details.dto'; import { DescriptionDto } from '../dto/description.dto'; -import { UserRegistrySearchService } from './userRegistry-search.service'; import { IUserRegistry } from '../interfaces/userRegistry.interface'; +import { UserRegistrySearchService } from './userRegistry-search.service'; @Injectable() export class UsersService {