From 83662102c3bbf3d43c9a62fa945637266d6c7b86 Mon Sep 17 00:00:00 2001
From: Jeremie BRISON <ext.sopra.jbrison@grandlyon.com>
Date: Thu, 3 Dec 2020 10:59:28 +0100
Subject: [PATCH] refacto(structure) : change model of structure

---
 src/structures/schemas/structure.schema.ts | 16 ++--------------
 src/structures/structures.controller.ts    |  6 +-----
 src/structures/structures.service.ts       |  4 ----
 3 files changed, 3 insertions(+), 23 deletions(-)

diff --git a/src/structures/schemas/structure.schema.ts b/src/structures/schemas/structure.schema.ts
index 821547e9f..878c39f04 100644
--- a/src/structures/schemas/structure.schema.ts
+++ b/src/structures/schemas/structure.schema.ts
@@ -112,22 +112,10 @@ export class Structure {
   cultureEtSecuriteNumerique: string[];
 
   @Prop()
-  wifiEnAccesLibre: boolean;
+  equipementsEtServicesProposes: string[];
 
   @Prop()
-  ordinateurs: boolean;
-
-  @Prop()
-  nombre: string;
-
-  @Prop()
-  tablettes: boolean;
-
-  @Prop()
-  bornesNumeriques: boolean;
-
-  @Prop()
-  imprimantes: boolean;
+  ordinateurs: number;
 
   @Prop()
   precisionsSiNecessaire: string;
diff --git a/src/structures/structures.controller.ts b/src/structures/structures.controller.ts
index 27fa79cc8..b3a33b8aa 100644
--- a/src/structures/structures.controller.ts
+++ b/src/structures/structures.controller.ts
@@ -35,11 +35,7 @@ export class StructuresController {
       this.structureService.countByStructureKey('publicsAcceptes'),
       this.structureService.countByStructureKey('modalitesDacces'),
       this.structureService.countByStructureKey('lesCompetencesDeBase'),
-      this.structureService.countByEquipmentsKey('wifiEnAccesLibre', 'Wifi en accès libre'),
-      this.structureService.countByEquipmentsKey('ordinateurs', 'Ordinateurs'),
-      this.structureService.countByEquipmentsKey('tablettes', 'Tablettes'),
-      this.structureService.countByEquipmentsKey('bornesNumeriques', 'Bornes numériques'),
-      this.structureService.countByEquipmentsKey('imprimantes', 'Imprimantes'),
+      this.structureService.countByStructureKey('equipementsEtServicesProposes'),
     ]);
     // Return a concat of all arrays
     return data.reduce((a, b) => [...a, ...b]);
diff --git a/src/structures/structures.service.ts b/src/structures/structures.service.ts
index 7c9b02198..9e52b0937 100644
--- a/src/structures/structures.service.ts
+++ b/src/structures/structures.service.ts
@@ -105,10 +105,6 @@ export class StructuresService {
     );
   }
 
-  public async countByEquipmentsKey(key: string, displayKey: string): Promise<any> {
-    return [{ id: displayKey, count: await this.structureModel.countDocuments({ [key]: true }).exec() }];
-  }
-
   public getCoord(numero: string, address: string, zipcode: string): Observable<AxiosResponse<any>> {
     const req =
       'https://download.data.grandlyon.com/geocoding/photon/api' + '?q=' + numero + ' ' + address + ' ' + zipcode;
-- 
GitLab