From a1568197036f8a87d902b2563fc35430a79d13c3 Mon Sep 17 00:00:00 2001
From: Antonin Coquet <ext.sopra.acoquet@grandlyon.com>
Date: Tue, 6 Apr 2021 17:35:16 +0200
Subject: [PATCH] feat: edit request for structure service (not working)

---
 src/structures/services/structures.service.ts | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts
index 5f1f1fec7..2ae465e15 100644
--- a/src/structures/services/structures.service.ts
+++ b/src/structures/services/structures.service.ts
@@ -188,13 +188,26 @@ export class StructuresService {
    * @return [{id: 'key', count: 'value'}]
    */
   public async countByStructureKey(key: string): Promise<any> {
+    console.log('key is:', key);
     const uniqueElements = await this.structureModel.distinct(key).exec();
+    console.log('unique elements:', uniqueElements);
     return await Promise.all(
       uniqueElements.map(async (value) => {
         return {
           id: value,
           count: await this.structureModel
-            .countDocuments({ $and: [{ [key]: { $elemMatch: { $eq: value } }, deletedAt: { $exists: false } }] })
+            .countDocuments({
+              $and: [
+                {
+                  [key]: { $elemMatch: { $eq: value } },
+                  //['proceduresAccompaniment']: { $elemMatch: { $eq: 'accompagnantCaf' } },
+                  deletedAt: { $exists: false },
+                },
+                {
+                  // ['proceduresAccompaniment']: { $elemMatch: { $eq: 'accompagnantCaf' } },
+                },
+              ],
+            })
             .exec(),
         };
       })
-- 
GitLab