Loading module/Oscar/src/Oscar/Controller/ProjectGrantController.php +43 −19 Original line number Diff line number Diff line Loading @@ -2742,24 +2742,6 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif public function advancedSearch2Action(): array|ViewModel { if ($this->isAjax() || $this->params()->fromQuery('format') === 'json') { $datas = []; $params = [ 'q' => $this->params()->fromQuery('q', ''), 'page' => $this->params()->fromQuery('page', 1), 'rbp' => $this->params()->fromQuery('rbp', 20), 'sort' => $this->params()->fromQuery('sort', 'hit'), 'direction' => $this->params()->fromQuery('direction', 'ASC'), 'filters' => $this->params()->fromQuery('f', []), 'project' => $this->params()->fromQuery('project') == '1' ?? '0', ]; $response = new JsonModel($this->getProjectGrantService()->search2($params)); return $response; } // Type de filtre $filters = [ "at" => [ Loading @@ -2776,17 +2758,59 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif "key" => 'ao', "label" => $this->oscarText("Organisation"), "raw" => 'ao;;' ], "psa" => [ "key" => 'psa', "label" => $this->oscarText("Projet sans activité"), "raw" => 'psa;;' ], "asp" => [ "key" => 'asp', "label" => $this->oscarText("Activité sans projet"), "raw" => 'asp;;' ] ]; $sorts = [ 'hit' => 'Pertinence de la recherche (textuelle)', 'dateUpdated' => 'Date de mise à jour', 'dateCreated' => 'Date de création', 'dateStart' => 'Date de début', 'dateEnd' => 'Date de fin', ]; $directions = [ 'desc' => 'Décroissant', 'asc' => 'Croissant', ]; if ($this->isAjax() || $this->params()->fromQuery('format') === 'json') { $params = [ 'q' => $this->params()->fromQuery('q', ''), 'page' => $this->params()->fromQuery('page', 1), 'rbp' => $this->params()->fromQuery('rbp', 20), 'sort' => $this->params()->fromQuery('sort', 'hit'), 'direction' => $this->params()->fromQuery('direction', 'desc'), 'filters' => $this->params()->fromQuery('f', []), 'project' => $this->params()->fromQuery('project') == '1' ?? '0', ]; $response = new JsonModel($this->getProjectGrantService()->search2($params)); return $response; } // Données pour la vue $filtersOptions = [ 'activityTypes' => $this->getActivityTypeService()->getActivityTypesTree(true), 'activityDocumentTypes' => $this->getProjectGrantSearchService()->getFilterOptionsMilestones(), 'filters' => $filters, 'sorts' => $sorts, 'directions' => $directions, ]; return [ 'filtersOptions' => $filtersOptions, 'urlShow' => $this->url()->fromRoute('contract/show', ['id' => '']) 'urlShow' => $this->url()->fromRoute('contract/show', ['id' => '']), 'urlShowProject' => $this->url()->fromRoute('project/show', ['id' => '']) ]; } Loading module/Oscar/src/Oscar/Service/ProjectGrantApiService.php +1 −0 Original line number Diff line number Diff line Loading @@ -576,6 +576,7 @@ class ProjectGrantApiService implements 'dateStart' => $this->formatDateTime($activity->getDateStart()), 'dateEnd' => $this->formatDateTime($activity->getDateEnd()), 'dateSigned' => $this->formatDateTime($activity->getDateSigned()), 'dateCreated' => $this->formatDateTime($activity->getDateCreated()), 'dateUpdated' => $this->formatDateTime($activity->getDateUpdated()), 'dateOpened' => $this->formatDateTime($activity->getDateOpened()), 'urls' => [ Loading module/Oscar/src/Oscar/Service/ProjectGrantService.php +13 −26 Original line number Diff line number Diff line Loading @@ -2146,6 +2146,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi $this->getSearchEngineStrategy()->addActivity($activity); } ////////////////////////////////////////////////// RECHERCHE v2 public function search2(array $params) { /** Construction de la requête **/ Loading @@ -2161,6 +2163,7 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi ]; $modeProject = $params['project'] == 1; $notices = []; if (array_key_exists('rbp', $params)) { if ($params['rbp'] <= 50) { Loading @@ -2178,7 +2181,6 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi $body['from'] = $from; $body['size'] = $size; if (array_key_exists('sort', $params) && $params['sort'] !== 'hit') { $direction = 'DESC'; if ($params['direction'] && in_array($params['direction'], ['ASC', 'DESC'])) { Loading @@ -2188,10 +2190,7 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } if (array_key_exists('filters', $params)) { $filterES = []; foreach ($params['filters'] as $filter) { $filterDatas = explode(';', $filter); Loading @@ -2213,12 +2212,22 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi "terms" => [$field => [$value1]], ]; break; default: $this->getLoggerService()->error("Le type de filtre '$type' n'est pas pris en charge"); } $body['query']['bool']['filter'] = array_values($filterES); } } $sortField = $params['sort']; $direction = $params['direction']; if( $sortField != 'hit' ){ $body['sort'] = [ $sortField => [ 'order' => $direction ] ]; } if ($params['project'] == '1') { $result = $this->getSearchEngineProjectStrategy()->searchRaw($params['q'], $limit = 1000, $body); Loading @@ -2244,28 +2253,6 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } $out["projects"] = $datas; // $datas = []; // $buckets = $result['aggregations']['projects']['buckets']; // $total = count($buckets); // $pages = ceil($total / $size); // for( $i=$from; $i<$size && $i<$total; $i++ ){ // $projectData = $buckets[$i]; // $project = $projectData['project']['hits']['hits'][0]['_source']['project']; // $activities = []; // foreach ($projectData['contracts']['hits']['hits'] as $activityHit){ // $activities[] = $activityHit['_source']; // } // $totalActivity = $projectData['contracts']['hits']['total']['value']; // $project["activities_total"] = $totalActivity; // $project["activities"] = $activities; // $datas[] = $project; // } // $out["projects"] = $datas; // echo "<pre>"; // echo json_encode($datas, JSON_PRETTY_PRINT); // echo "<pre>"; json_encode($result, JSON_PRETTY_PRINT); die(); // echo json_encode($body, JSON_PRETTY_PRINT); die(); } else { $total = $result['hits']['total']['value']; $pages = ceil($total / $size); Loading module/Oscar/src/Oscar/Strategy/Search/ElasticActivitySearch.php +0 −2 Original line number Diff line number Diff line Loading @@ -84,11 +84,9 @@ class ElasticActivitySearch extends ElasticSearchEngine implements IActivitySear 'date' => ['type' => 'date'], ] ], // // 'numerotation' => [ 'type' => 'text', 'analyzer' => 'folding_analyzer'], // 'numbers' => [ 'type' => 'nested' ], 'description' => ['type' => 'text'], ] ] ]; Loading module/Oscar/src/Oscar/Strategy/Search/ProjectElasticSearch.php +12 −7 Original line number Diff line number Diff line Loading @@ -49,10 +49,12 @@ class ProjectElasticSearch extends ElasticSearchEngine 'acronym' => ['type' => 'text'], 'label' => ['type' => 'text'], 'description' => ['type' => 'text'], 'dateStart' => ['type' => 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'], 'dateEnd' => ['type' => 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'], 'dateCreated' => ['type' => 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'], 'dateUpdated' => ['type' => 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'], 'activities' => [ 'type' => 'nested', 'type' => 'object', 'properties' => [ "id" => ['type' => 'keyword'], "label" => ['type' => 'text'], Loading Loading @@ -91,18 +93,16 @@ class ProjectElasticSearch extends ElasticSearchEngine $amount = 0.0; $hasFinancial = false; $type_id = []; $type_chain_id = []; $oscar = []; $type_chain_id = []; $type_chain_label = []; foreach ($object->getActivities() as $activity) { $type_id = null; $type_chain_id = []; $type_chain_label = []; if ($activity->getActivityType()) { $type_id[] = $activity->getActivityType()->getId(); $type_chain_id = array_merge($type_chain_id, $this->staticDatas['typesChainIds'][$activity->getActivityType()->getId()]); $type_chain_label = array_merge($type_chain_id, $this->staticDatas['typesChainlabels'][$activity->getActivityType()->getId()]); $type_chain_label = array_merge($type_chain_label, $this->staticDatas['typesChainlabels'][$activity->getActivityType()->getId()]); } $oscar[] = $activity->getOscarNum(); Loading Loading @@ -235,13 +235,18 @@ class ProjectElasticSearch extends ElasticSearchEngine // Champ ACRONYM $query["bool"]["should"][] = ["match" => ["acronym" => ["query" => $search, "fuzziness" => 1, "boost" => 20]]]; $query["bool"]["should"][] = ["match" => ["eotps" => ["query" => $search, "fuzziness" => 1, "boost" => 20]]]; $query["bool"]["should"][] = ["match" => ["oscar" => ["query" => $search, "boost" => 10]]]; $query["bool"]["should"][] = ["prefix" => ["acronym" => ["value" => strtolower($search), "boost" => 5]]]; $query["bool"]["should"][] = ["prefix" => ["oscar" => ["value" => strtolower($search), "boost" => 5]]]; $query["bool"]["should"][] = ["prefix" => ["eotps" => ["value" => $search, "boost" => 5]]]; // Champ LABEL/PROJECT LABEL $query["bool"]["should"][] = ["match" => ["label" => ["query" => $search, "fuzziness" => 1, "boost" => 4]]]; $query["bool"]["should"][] = ["match" => ["description" => ["query" => $search, "fuzziness" => 1]]]; $query["bool"]["should"][] = ["match" => ["activities.label" => ["query" => $search, "fuzziness" => 1]]]; $query["bool"]["should"][] = ["match" => ["activities.label" => ["query" => $search, "fuzziness" => 1, "boost" => 2]]]; $query["bool"]["should"][] = ["match" => ["activities.description" => ["query" => $search, "fuzziness" => 1]]]; return $query; } Loading Loading
module/Oscar/src/Oscar/Controller/ProjectGrantController.php +43 −19 Original line number Diff line number Diff line Loading @@ -2742,24 +2742,6 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif public function advancedSearch2Action(): array|ViewModel { if ($this->isAjax() || $this->params()->fromQuery('format') === 'json') { $datas = []; $params = [ 'q' => $this->params()->fromQuery('q', ''), 'page' => $this->params()->fromQuery('page', 1), 'rbp' => $this->params()->fromQuery('rbp', 20), 'sort' => $this->params()->fromQuery('sort', 'hit'), 'direction' => $this->params()->fromQuery('direction', 'ASC'), 'filters' => $this->params()->fromQuery('f', []), 'project' => $this->params()->fromQuery('project') == '1' ?? '0', ]; $response = new JsonModel($this->getProjectGrantService()->search2($params)); return $response; } // Type de filtre $filters = [ "at" => [ Loading @@ -2776,17 +2758,59 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif "key" => 'ao', "label" => $this->oscarText("Organisation"), "raw" => 'ao;;' ], "psa" => [ "key" => 'psa', "label" => $this->oscarText("Projet sans activité"), "raw" => 'psa;;' ], "asp" => [ "key" => 'asp', "label" => $this->oscarText("Activité sans projet"), "raw" => 'asp;;' ] ]; $sorts = [ 'hit' => 'Pertinence de la recherche (textuelle)', 'dateUpdated' => 'Date de mise à jour', 'dateCreated' => 'Date de création', 'dateStart' => 'Date de début', 'dateEnd' => 'Date de fin', ]; $directions = [ 'desc' => 'Décroissant', 'asc' => 'Croissant', ]; if ($this->isAjax() || $this->params()->fromQuery('format') === 'json') { $params = [ 'q' => $this->params()->fromQuery('q', ''), 'page' => $this->params()->fromQuery('page', 1), 'rbp' => $this->params()->fromQuery('rbp', 20), 'sort' => $this->params()->fromQuery('sort', 'hit'), 'direction' => $this->params()->fromQuery('direction', 'desc'), 'filters' => $this->params()->fromQuery('f', []), 'project' => $this->params()->fromQuery('project') == '1' ?? '0', ]; $response = new JsonModel($this->getProjectGrantService()->search2($params)); return $response; } // Données pour la vue $filtersOptions = [ 'activityTypes' => $this->getActivityTypeService()->getActivityTypesTree(true), 'activityDocumentTypes' => $this->getProjectGrantSearchService()->getFilterOptionsMilestones(), 'filters' => $filters, 'sorts' => $sorts, 'directions' => $directions, ]; return [ 'filtersOptions' => $filtersOptions, 'urlShow' => $this->url()->fromRoute('contract/show', ['id' => '']) 'urlShow' => $this->url()->fromRoute('contract/show', ['id' => '']), 'urlShowProject' => $this->url()->fromRoute('project/show', ['id' => '']) ]; } Loading
module/Oscar/src/Oscar/Service/ProjectGrantApiService.php +1 −0 Original line number Diff line number Diff line Loading @@ -576,6 +576,7 @@ class ProjectGrantApiService implements 'dateStart' => $this->formatDateTime($activity->getDateStart()), 'dateEnd' => $this->formatDateTime($activity->getDateEnd()), 'dateSigned' => $this->formatDateTime($activity->getDateSigned()), 'dateCreated' => $this->formatDateTime($activity->getDateCreated()), 'dateUpdated' => $this->formatDateTime($activity->getDateUpdated()), 'dateOpened' => $this->formatDateTime($activity->getDateOpened()), 'urls' => [ Loading
module/Oscar/src/Oscar/Service/ProjectGrantService.php +13 −26 Original line number Diff line number Diff line Loading @@ -2146,6 +2146,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi $this->getSearchEngineStrategy()->addActivity($activity); } ////////////////////////////////////////////////// RECHERCHE v2 public function search2(array $params) { /** Construction de la requête **/ Loading @@ -2161,6 +2163,7 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi ]; $modeProject = $params['project'] == 1; $notices = []; if (array_key_exists('rbp', $params)) { if ($params['rbp'] <= 50) { Loading @@ -2178,7 +2181,6 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi $body['from'] = $from; $body['size'] = $size; if (array_key_exists('sort', $params) && $params['sort'] !== 'hit') { $direction = 'DESC'; if ($params['direction'] && in_array($params['direction'], ['ASC', 'DESC'])) { Loading @@ -2188,10 +2190,7 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } if (array_key_exists('filters', $params)) { $filterES = []; foreach ($params['filters'] as $filter) { $filterDatas = explode(';', $filter); Loading @@ -2213,12 +2212,22 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi "terms" => [$field => [$value1]], ]; break; default: $this->getLoggerService()->error("Le type de filtre '$type' n'est pas pris en charge"); } $body['query']['bool']['filter'] = array_values($filterES); } } $sortField = $params['sort']; $direction = $params['direction']; if( $sortField != 'hit' ){ $body['sort'] = [ $sortField => [ 'order' => $direction ] ]; } if ($params['project'] == '1') { $result = $this->getSearchEngineProjectStrategy()->searchRaw($params['q'], $limit = 1000, $body); Loading @@ -2244,28 +2253,6 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi } $out["projects"] = $datas; // $datas = []; // $buckets = $result['aggregations']['projects']['buckets']; // $total = count($buckets); // $pages = ceil($total / $size); // for( $i=$from; $i<$size && $i<$total; $i++ ){ // $projectData = $buckets[$i]; // $project = $projectData['project']['hits']['hits'][0]['_source']['project']; // $activities = []; // foreach ($projectData['contracts']['hits']['hits'] as $activityHit){ // $activities[] = $activityHit['_source']; // } // $totalActivity = $projectData['contracts']['hits']['total']['value']; // $project["activities_total"] = $totalActivity; // $project["activities"] = $activities; // $datas[] = $project; // } // $out["projects"] = $datas; // echo "<pre>"; // echo json_encode($datas, JSON_PRETTY_PRINT); // echo "<pre>"; json_encode($result, JSON_PRETTY_PRINT); die(); // echo json_encode($body, JSON_PRETTY_PRINT); die(); } else { $total = $result['hits']['total']['value']; $pages = ceil($total / $size); Loading
module/Oscar/src/Oscar/Strategy/Search/ElasticActivitySearch.php +0 −2 Original line number Diff line number Diff line Loading @@ -84,11 +84,9 @@ class ElasticActivitySearch extends ElasticSearchEngine implements IActivitySear 'date' => ['type' => 'date'], ] ], // // 'numerotation' => [ 'type' => 'text', 'analyzer' => 'folding_analyzer'], // 'numbers' => [ 'type' => 'nested' ], 'description' => ['type' => 'text'], ] ] ]; Loading
module/Oscar/src/Oscar/Strategy/Search/ProjectElasticSearch.php +12 −7 Original line number Diff line number Diff line Loading @@ -49,10 +49,12 @@ class ProjectElasticSearch extends ElasticSearchEngine 'acronym' => ['type' => 'text'], 'label' => ['type' => 'text'], 'description' => ['type' => 'text'], 'dateStart' => ['type' => 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'], 'dateEnd' => ['type' => 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'], 'dateCreated' => ['type' => 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'], 'dateUpdated' => ['type' => 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'], 'activities' => [ 'type' => 'nested', 'type' => 'object', 'properties' => [ "id" => ['type' => 'keyword'], "label" => ['type' => 'text'], Loading Loading @@ -91,18 +93,16 @@ class ProjectElasticSearch extends ElasticSearchEngine $amount = 0.0; $hasFinancial = false; $type_id = []; $type_chain_id = []; $oscar = []; $type_chain_id = []; $type_chain_label = []; foreach ($object->getActivities() as $activity) { $type_id = null; $type_chain_id = []; $type_chain_label = []; if ($activity->getActivityType()) { $type_id[] = $activity->getActivityType()->getId(); $type_chain_id = array_merge($type_chain_id, $this->staticDatas['typesChainIds'][$activity->getActivityType()->getId()]); $type_chain_label = array_merge($type_chain_id, $this->staticDatas['typesChainlabels'][$activity->getActivityType()->getId()]); $type_chain_label = array_merge($type_chain_label, $this->staticDatas['typesChainlabels'][$activity->getActivityType()->getId()]); } $oscar[] = $activity->getOscarNum(); Loading Loading @@ -235,13 +235,18 @@ class ProjectElasticSearch extends ElasticSearchEngine // Champ ACRONYM $query["bool"]["should"][] = ["match" => ["acronym" => ["query" => $search, "fuzziness" => 1, "boost" => 20]]]; $query["bool"]["should"][] = ["match" => ["eotps" => ["query" => $search, "fuzziness" => 1, "boost" => 20]]]; $query["bool"]["should"][] = ["match" => ["oscar" => ["query" => $search, "boost" => 10]]]; $query["bool"]["should"][] = ["prefix" => ["acronym" => ["value" => strtolower($search), "boost" => 5]]]; $query["bool"]["should"][] = ["prefix" => ["oscar" => ["value" => strtolower($search), "boost" => 5]]]; $query["bool"]["should"][] = ["prefix" => ["eotps" => ["value" => $search, "boost" => 5]]]; // Champ LABEL/PROJECT LABEL $query["bool"]["should"][] = ["match" => ["label" => ["query" => $search, "fuzziness" => 1, "boost" => 4]]]; $query["bool"]["should"][] = ["match" => ["description" => ["query" => $search, "fuzziness" => 1]]]; $query["bool"]["should"][] = ["match" => ["activities.label" => ["query" => $search, "fuzziness" => 1]]]; $query["bool"]["should"][] = ["match" => ["activities.label" => ["query" => $search, "fuzziness" => 1, "boost" => 2]]]; $query["bool"]["should"][] = ["match" => ["activities.description" => ["query" => $search, "fuzziness" => 1]]]; return $query; } Loading