From 9d9b69d3b36e6f3f5576ce016e4fa56dd838750a Mon Sep 17 00:00:00 2001 From: Thibault CABANES-YZIQUEL Date: Thu, 31 Jan 2019 15:00:14 +0100 Subject: [PATCH 1/5] [FEATURE#105983] Warning demande et suppression de creneaux (provider) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit voici une étape dans laquelle j'utilise une aggregation dans le but de pouvoir récupérer les contract Ids par type de demande (add ou cancellation) je crée aussi sa route --- src/ChangeRequestManager.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ChangeRequestManager.php b/src/ChangeRequestManager.php index be4d8eb..273f876 100644 --- a/src/ChangeRequestManager.php +++ b/src/ChangeRequestManager.php @@ -42,6 +42,25 @@ function ($hit) { return $response; } + public function findByQueryStringAndAgg($query, $aggs, $from = 0, $size = 999999, $sort = "") + { + $query = urlencode($query); + $body = ["aggs" => $aggs]; + + $response = $this->fireRequest("GET", "/search?q={$query}&from={$from}&size={$size}&sort={$sort}", $body); + + $response["hits"] = array_map( + function ($hit) { + $change_todos = new ChangeTodos(); + $change_todos->fromArray($hit); + return $change_todos; + }, + $response["hits"] + ); + + return $response; + } + public function findOneByQueryString($query) { $matching = $this->findByQueryString($query, 0, 1); From 411ef5985071439024dfad6bd30f10b65213f62b Mon Sep 17 00:00:00 2001 From: Thibault CABANES-YZIQUEL Date: Mon, 11 Feb 2019 16:08:19 +0100 Subject: [PATCH 2/5] [FEATURE#105983] modification sur les retour des fonction pour warning retrait de la fonction en trop, et modifiaction e lexistente en ajoutant un parametre modification des retour --- src/ChangeRequestManager.php | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/src/ChangeRequestManager.php b/src/ChangeRequestManager.php index 273f876..fc65f1c 100644 --- a/src/ChangeRequestManager.php +++ b/src/ChangeRequestManager.php @@ -24,38 +24,24 @@ public function __construct(Application $app = null) $this->app = $app; } - public function findByQueryString($query, $from = 0, $size = 99999, $sort = "") + public function findByQueryString($query, $from = 0, $size = 99999, $sort = "", $aggs = []) { $query = urlencode($query); + $body = []; - $response = $this->fireRequest("GET", "/search?q={$query}&from={$from}&size={$size}&sort={$sort}"); - - $response["hits"] = array_map( - function ($hit) { - $change_todos = new ChangeTodos(); - $change_todos->fromArray($hit); - return $change_todos; - }, - $response["hits"] - ); - - return $response; - } - - public function findByQueryStringAndAgg($query, $aggs, $from = 0, $size = 999999, $sort = "") - { - $query = urlencode($query); - $body = ["aggs" => $aggs]; + if (!empty($aggs)) { + $body = ["aggs" => $aggs]; + } $response = $this->fireRequest("GET", "/search?q={$query}&from={$from}&size={$size}&sort={$sort}", $body); - $response["hits"] = array_map( + $response["hits"]["hits"] = array_map( function ($hit) { $change_todos = new ChangeTodos(); $change_todos->fromArray($hit); return $change_todos; }, - $response["hits"] + $response["hits"]["hits"] ); return $response; @@ -65,11 +51,11 @@ public function findOneByQueryString($query) { $matching = $this->findByQueryString($query, 0, 1); - if (0 === count($matching["hits"])) { + if (0 === count($matching["hits"]["hits"])) { return null; } - $change_request = $matching["hits"][0]; + $change_request = $matching["hits"]["hits"][0]; return $change_request; } From 46e6a8ef0daae2ee6c60a02848270e2129d2a76b Mon Sep 17 00:00:00 2001 From: Thibault CABANES-YZIQUEL Date: Tue, 19 Feb 2019 09:55:48 +0100 Subject: [PATCH 3/5] [FEATURE#105983] nouvelle route ajout d'une nouvelle route --- src/ChangeRequestManager.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/ChangeRequestManager.php b/src/ChangeRequestManager.php index fc65f1c..73131b3 100644 --- a/src/ChangeRequestManager.php +++ b/src/ChangeRequestManager.php @@ -24,7 +24,26 @@ public function __construct(Application $app = null) $this->app = $app; } - public function findByQueryString($query, $from = 0, $size = 99999, $sort = "", $aggs = []) + public function findByQueryString($query, $from = 0, $size = 99999, $sort = "") + { + $query = urlencode($query); + + $response = $this->fireRequest("GET", "/search?q={$query}&from={$from}&size={$size}&sort={$sort}"); + + $response["hits"] = array_map( + function ($hit) { + $change_todos = new ChangeTodos(); + $change_todos->fromArray($hit); + + return $change_todos; + }, + $response["hits"] + ); + + return $response; + } + + public function findByQueryStringAndAggs($query, $from = 0, $size = 99999, $sort = "", $aggs = []) { $query = urlencode($query); $body = []; @@ -33,8 +52,7 @@ public function findByQueryString($query, $from = 0, $size = 99999, $sort = "", $body = ["aggs" => $aggs]; } - $response = $this->fireRequest("GET", "/search?q={$query}&from={$from}&size={$size}&sort={$sort}", $body); - + $response = $this->fireRequest("POST", "/aggs?q={$query}&from={$from}&size={$size}&sort={$sort}", $body); $response["hits"]["hits"] = array_map( function ($hit) { $change_todos = new ChangeTodos(); @@ -51,11 +69,11 @@ public function findOneByQueryString($query) { $matching = $this->findByQueryString($query, 0, 1); - if (0 === count($matching["hits"]["hits"])) { + if (0 === count($matching["hits"])) { return null; } - $change_request = $matching["hits"]["hits"][0]; + $change_request = $matching["hits"][0]; return $change_request; } From 54a897eb7c56b1abca3bcef32f4a416b293fcda8 Mon Sep 17 00:00:00 2001 From: Thibault CABANES-YZIQUEL Date: Tue, 19 Feb 2019 09:59:14 +0100 Subject: [PATCH 4/5] [FEATURE#105983] Retrait espaces espace en trop --- src/ChangeRequestManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ChangeRequestManager.php b/src/ChangeRequestManager.php index 73131b3..76e2034 100644 --- a/src/ChangeRequestManager.php +++ b/src/ChangeRequestManager.php @@ -29,7 +29,7 @@ public function findByQueryString($query, $from = 0, $size = 99999, $sort = "") $query = urlencode($query); $response = $this->fireRequest("GET", "/search?q={$query}&from={$from}&size={$size}&sort={$sort}"); - + $response["hits"] = array_map( function ($hit) { $change_todos = new ChangeTodos(); From d52cf9206e85e4a1827e166775ab5629a428a5d4 Mon Sep 17 00:00:00 2001 From: Thibault CABANES-YZIQUEL Date: Thu, 21 Feb 2019 15:35:47 +0100 Subject: [PATCH 5/5] [FEATURE#105983] correction pr Saut de lignes --- src/ChangeRequestManager.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ChangeRequestManager.php b/src/ChangeRequestManager.php index 76e2034..fee0a9a 100644 --- a/src/ChangeRequestManager.php +++ b/src/ChangeRequestManager.php @@ -53,10 +53,12 @@ public function findByQueryStringAndAggs($query, $from = 0, $size = 99999, $sort } $response = $this->fireRequest("POST", "/aggs?q={$query}&from={$from}&size={$size}&sort={$sort}", $body); + $response["hits"]["hits"] = array_map( function ($hit) { $change_todos = new ChangeTodos(); $change_todos->fromArray($hit); + return $change_todos; }, $response["hits"]["hits"]