diff --git a/src/structures/schemas/structure.schema.ts b/src/structures/schemas/structure.schema.ts index 937b5519adfb8a4e0a90e15392532f9c672c9b50..d6808c9c811d0e7089347aad5f03385de2afd3e6 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 7a6e1a65a0edad5aeb305984f234bbda5df21978..69019073e471f7fffa3d9599212ee3ccd8c7ba95 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 0b6de20bf323812fbc7e361f5770dfc3ea633414..ca013633e1d89485cf16dae99e49920e13bc349d 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()