From 416654e6165072314f91d7db3924dd730dbe471b Mon Sep 17 00:00:00 2001
From: Antonin Coquet <ext.sopra.acoquet@grandlyon.com>
Date: Fri, 30 Apr 2021 14:46:58 +0200
Subject: [PATCH] fix: fix number of results for ES and filters count

---
 src/structures/services/structures-search.service.ts | 2 +-
 src/structures/services/structures.service.ts        | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/structures/services/structures-search.service.ts b/src/structures/services/structures-search.service.ts
index f334926a9..e809c58f9 100644
--- a/src/structures/services/structures-search.service.ts
+++ b/src/structures/services/structures-search.service.ts
@@ -59,7 +59,7 @@ export class StructuresSearchService {
       index: this.index,
       body: {
         from: 0,
-        size: 30,
+        size: 200,
         query: {
           query_string: {
             analyze_wildcard: 'true',
diff --git a/src/structures/services/structures.service.ts b/src/structures/services/structures.service.ts
index 8b98603ab..ae5c8dd48 100644
--- a/src/structures/services/structures.service.ts
+++ b/src/structures/services/structures.service.ts
@@ -58,6 +58,7 @@ export class StructuresService {
         await this.structureModel
           .find({
             _id: { $in: ids },
+            $and: [{ deletedAt: { $exists: false }, accountVerified: true }],
           })
           .exec()
       ).sort((a, b) => ids.indexOf(a.id) - ids.indexOf(b.id));
@@ -160,7 +161,7 @@ export class StructuresService {
     );
     return structures;
   }
-  
+
   public async findAllFormated(
     formationCategories: CategoriesFormations[],
     accompagnementCategories: CategoriesAccompagnement[],
@@ -353,12 +354,14 @@ export class StructuresService {
         keyList.push({
           [key]: { $elemMatch: { $eq: value } },
           deletedAt: { $exists: false },
+          accountVerified: true,
         });
         if (selected && selected.length > 0) {
           for (const val of selected) {
             keyList.push({
               [val.text]: { $elemMatch: { $eq: val.id } },
               deletedAt: { $exists: false },
+              accountVerified: true,
             });
           }
         }
-- 
GitLab