diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts index 64c304a7f10e65a7ecd60e6afe5ac9fda0cebb79..bf325484cbd7f1dda06e79530e7ddfbf81fa0c05 100644 --- a/src/structures/services/structures.service.ts +++ b/src/structures/services/structures.service.ts @@ -630,7 +630,7 @@ export class StructuresService { structure.address.inseeCode = inseeCode; const ctm: Module = await this.categoriesService.findCtmByInseeCode(inseeCode); if (ctm) { - this.logger.debug(`${structure.structureName} : CTM ${ctm.id}`); + this.logger.log(`${structure.structureName} : CTM ${ctm.id}`); structure.categories['ctm'] = [ctm.id]; } } @@ -1333,11 +1333,10 @@ export class StructuresService { this.logger.debug('setCTMs'); const structures: StructureDocument[] = await this.findAll(); for (const structure of structures) { - this.setCtmTerritory(structure).then(async (updatedStructure) => { - await this.structureModel - .findByIdAndUpdate(new Types.ObjectId(structure._id), updatedStructure, { timestamps: false }) - .exec(); - }); + const updatedStructure = await this.setCtmTerritory(structure); + await this.structureModel + .findByIdAndUpdate(new Types.ObjectId(structure._id), updatedStructure, { timestamps: false }) + .exec(); } return null; } diff --git a/src/structures/structures.controller.ts b/src/structures/structures.controller.ts index fe62766f74a30f95c36ff8c3bea30f4a40461d1e..01a59588116d756204f22dadf6f79d2af7f32a70 100644 --- a/src/structures/structures.controller.ts +++ b/src/structures/structures.controller.ts @@ -204,7 +204,7 @@ export class StructuresController { @UseGuards(JwtAuthGuard, RolesGuard) @Roles('admin') public async updateCTM(): Promise<void> { - this.logger.debug('updateCTM'); + this.logger.log('updateCTM'); await this.categoriesService.updateCTM(); return this.structureService.setCTMs(); }