From e788e55e0c63155c5994b39cbc2f37871f2b4398 Mon Sep 17 00:00:00 2001 From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com> Date: Mon, 18 Jan 2021 12:12:37 +0100 Subject: [PATCH] fix: unecessary id declaration in model structure --- src/structures/schemas/structure.schema.ts | 6 ------ src/structures/services/aptic-structures.service.ts | 3 ++- src/structures/services/structures.service.ts | 6 +++--- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/structures/schemas/structure.schema.ts b/src/structures/schemas/structure.schema.ts index 937b5519a..d6808c9c8 100644 --- a/src/structures/schemas/structure.schema.ts +++ b/src/structures/schemas/structure.schema.ts @@ -7,12 +7,6 @@ export type StructureDocument = Structure & Document; @Schema({ timestamps: { createdAt: 'createdAt', updatedAt: 'updatedAt' } }) export class Structure { - @Prop({ type: Types.ObjectId }) - _id: string; - - @Prop() - id: number; - @Prop() numero: string; diff --git a/src/structures/services/aptic-structures.service.ts b/src/structures/services/aptic-structures.service.ts index 7a6e1a65a..69019073e 100644 --- a/src/structures/services/aptic-structures.service.ts +++ b/src/structures/services/aptic-structures.service.ts @@ -55,6 +55,7 @@ export class ApticStructuresService { address.street = structure.presence_address; address.commune = structure.city; createdStructure.address = address; + console.log('structure: ', createdStructure); createdStructure.save(); } }); @@ -84,7 +85,7 @@ export class ApticStructuresService { /** * Get Metropole new aptic structure evey first day of month at midnight. For testign, please change the expression */ - @Cron(CronExpression.EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT) + @Cron(CronExpression.EVERY_MINUTE) public getMetopoleMunicipality(): void { const req = 'https://download.data.grandlyon.com/ws/grandlyon/adr_voie_lieu.adrcomgl/all.json?maxfeatures=-1&start=1'; diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts index 0b6de20bf..ca013633e 100644 --- a/src/structures/services/structures.service.ts +++ b/src/structures/services/structures.service.ts @@ -57,11 +57,11 @@ export class StructuresService { }); } - public async findAll(): Promise<Structure[]> { + public async findAll(): Promise<StructureDocument[]> { const structures = await this.structureModel.find().exec(); // Update structures coord and address before sending them await Promise.all( - structures.map((structure: Structure) => { + structures.map((structure: StructureDocument) => { // If structre has no address, add it if (!structure.address) { return this.getStructurePosition(structure).then((postition) => { @@ -72,7 +72,7 @@ export class StructuresService { } if (structure.coord.length <= 0) { return new Promise((resolve) => { - this.getStructurePosition(structure).then((postition) => { + this.getStructurePosition(structure).then((postition: StructureDocument) => { this.structureModel .findByIdAndUpdate(Types.ObjectId(postition._id), { coord: postition.coord }) .exec() -- GitLab