Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server
1 result
Show changes
Commits on Source (3)
......@@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [2.0.1](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v2.0.0...v2.0.1) (2022-12-05)
### Features
* Add limit number for structure search ([ad7ff86](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/commit/ad7ff86155fc15b5bca43f215b8abcb60d848280))
## [2.0.0](https://forge.grandlyon.com/web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server/compare/v2.0.0-beta5...v2.0.0) (2022-12-02)
......
{
"name": "ram_server",
"version": "2.0.0",
"version": "2.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
{
"name": "ram_server",
"private": true,
"version": "2.0.0",
"version": "2.0.1",
"description": "Nest TypeScript starter repository",
"license": "MIT",
"scripts": {
......
......@@ -37,6 +37,7 @@ const mockStructureModel = {
countDocuments: jest.fn(),
findOne: jest.fn(),
findById: jest.fn(),
limit: jest.fn(),
findByIdAndUpdate: jest.fn(),
exec: jest.fn(),
find: jest.fn(),
......@@ -290,6 +291,7 @@ describe('StructuresService', () => {
describe('searchForStructures', () => {
jest.setTimeout(30000);
mockStructureModel.find.mockReturnThis();
mockStructureModel.limit.mockReturnThis();
mockStructureModel.populate.mockReturnThis();
mockStructureModel.exec.mockResolvedValue([
{
......@@ -603,6 +605,7 @@ describe('StructuresService', () => {
jest.spyOn(service, 'findAll').mockResolvedValue(mockResinStructures as StructureDocument[]);
mockStructureModel.findByIdAndUpdate.mockReturnThis();
mockStructureModel.findById.mockReturnThis();
mockStructureModel.limit.mockReturnThis();
mockStructureModel.populate.mockReturnThis();
mockStructureModel.exec.mockResolvedValueOnce([]);
expect(await service.bindCNFSids()).toBe(`2 structures affected`);
......
......@@ -56,7 +56,12 @@ export class StructuresService {
});
}
async searchForStructures(text: string, filters?: Array<any>, fields?: string[]): Promise<StructureDocument[]> {
async searchForStructures(
text: string,
filters?: Array<any>,
fields?: string[],
limit?: number
): Promise<StructureDocument[]> {
this.logger.debug(
`searchForStructures : ${text} | filters: ${JSON.stringify(filters)} | fields : ${JSON.stringify(fields)} | `
);
......@@ -86,6 +91,7 @@ export class StructuresService {
})
.populate('personalOffers')
.populate('structureType')
.limit(limit)
.exec();
} else if (filters?.length > 0 && multipleFilters?.length > 0) {
structures = await this.structureModel
......@@ -96,6 +102,7 @@ export class StructuresService {
})
.populate('personalOffers')
.populate('structureType')
.limit(limit)
.exec();
} else if (filters?.length == 0 && multipleFilters?.length > 0) {
structures = await this.structureModel
......@@ -105,6 +112,7 @@ export class StructuresService {
})
.populate('personalOffers')
.populate('structureType')
.limit(limit)
.exec();
} else {
structures = await this.structureModel
......@@ -114,6 +122,7 @@ export class StructuresService {
})
.populate('personalOffers')
.populate('structureType')
.limit(limit)
.exec();
}
......
......@@ -81,7 +81,12 @@ export class StructuresController {
@Post('search')
public async search(@Query() query: QueryStructure, @Body() body): Promise<Structure[]> {
this.logger.debug(`search`);
return this.structureService.searchForStructures(query.query, body ? body.filters : null);
return this.structureService.searchForStructures(
query.query,
body ? body.filters : null,
null,
body?.limit || null
);
}
@Post('searchByName')
......