Loading module/Oscar/config/module.config.php +1 −0 Original line number Diff line number Diff line Loading @@ -151,6 +151,7 @@ return array( [ 'controller' => 'Activity', 'action' => [ 'advancedsearch2', 'show', 'show2', 'edit', Loading module/Oscar/config/routes.yml +8 −1 Original line number Diff line number Diff line Loading @@ -804,7 +804,7 @@ organization: may_terminate: true defaults: controller: Organization action: index action: index2 may_terminate: true child_routes: Loading Loading @@ -1020,6 +1020,13 @@ contract: defaults: action: advancedSearch advancedsearch2: type: segment options: route: /advancedsearch2 defaults: action: advancedSearch2 api: type: segment options: Loading module/Oscar/src/Oscar/Controller/OrganizationController.php +2 −1 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ class OrganizationController extends AbstractOscarController implements UseOrgan { $types = $this->getOrganizationService()->getOrganizationTypesSelect(); $sorting = [ 'hit' => 'Pertinence (recherche textuelle)', 'shortName' => 'Nom court', Loading Loading @@ -140,7 +141,7 @@ class OrganizationController extends AbstractOscarController implements UseOrgan } if( $this->isAjax() || $this->params()->fromQuery('f') === 'json'){ //$this->getOscarUserContextService()->check("UNDEFINED_PRIVIEGE"); $this->getLoggerService()->debug("Search organization"); try { $page = (int)$this->params()->fromQuery('page', 1); $search = $this->params()->fromQuery('q', ''); Loading module/Oscar/src/Oscar/Controller/ProjectGrantController.php +17 −0 Original line number Diff line number Diff line Loading @@ -2776,6 +2776,23 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif return $this->applyAdvancedSearch(); } public function advancedSearch2Action(): array|ViewModel { if( $this->isAjax() || $this->params()->fromQuery('f') === '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'), ]; $response = new JsonModel($this->getProjectGrantService()->search2($params)); return $response; } return []; } /** * Liste des activités de recherche. */ Loading module/Oscar/src/Oscar/Service/ProjectGrantService.php +30 −1 Original line number Diff line number Diff line Loading @@ -1202,6 +1202,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi $this->getEntityManager()->flush($entity); } protected function debug__displayIds(array $ids) { echo " = "; Loading Loading @@ -2147,6 +2149,26 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi $this->getSearchEngineStrategy()->addActivity($activity); } public function search2(array $params) { /** Construction de la requête **/ $body = []; $result = $this->getSearchEngineStrategy()->searchRaw($params['q'], $limit = 1000, $body); $total = $result['hits']['total']['value']; $datas = []; foreach ($result['hits']['hits'] as $item) { $datas[] = $item['_source']; } return [ 'total' => $total, 'activities' => $datas, 'query' => $body ]; } /** * Retourne les jalons de l'activité. * Loading @@ -2160,7 +2182,14 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi public function searchIndex_rebuild() { $activities = $this->getEntityManager()->getRepository(Activity::class)->findAll(); //$activities = $this->getEntityManager()->getRepository(Activity::class)->findAll(); $activities = $this->getEntityManager()->getRepository(Activity::class)->findBy( [], ['dateUpdated' => 'DESC'], 10, 0 ); $this->getLoggerService()->info('[elasic] Reindex ' . count($activities) . ' activitie(s)'); return $this->getSearchEngineStrategy()->rebuildIndex($activities); } Loading Loading
module/Oscar/config/module.config.php +1 −0 Original line number Diff line number Diff line Loading @@ -151,6 +151,7 @@ return array( [ 'controller' => 'Activity', 'action' => [ 'advancedsearch2', 'show', 'show2', 'edit', Loading
module/Oscar/config/routes.yml +8 −1 Original line number Diff line number Diff line Loading @@ -804,7 +804,7 @@ organization: may_terminate: true defaults: controller: Organization action: index action: index2 may_terminate: true child_routes: Loading Loading @@ -1020,6 +1020,13 @@ contract: defaults: action: advancedSearch advancedsearch2: type: segment options: route: /advancedsearch2 defaults: action: advancedSearch2 api: type: segment options: Loading
module/Oscar/src/Oscar/Controller/OrganizationController.php +2 −1 Original line number Diff line number Diff line Loading @@ -112,6 +112,7 @@ class OrganizationController extends AbstractOscarController implements UseOrgan { $types = $this->getOrganizationService()->getOrganizationTypesSelect(); $sorting = [ 'hit' => 'Pertinence (recherche textuelle)', 'shortName' => 'Nom court', Loading Loading @@ -140,7 +141,7 @@ class OrganizationController extends AbstractOscarController implements UseOrgan } if( $this->isAjax() || $this->params()->fromQuery('f') === 'json'){ //$this->getOscarUserContextService()->check("UNDEFINED_PRIVIEGE"); $this->getLoggerService()->debug("Search organization"); try { $page = (int)$this->params()->fromQuery('page', 1); $search = $this->params()->fromQuery('q', ''); Loading
module/Oscar/src/Oscar/Controller/ProjectGrantController.php +17 −0 Original line number Diff line number Diff line Loading @@ -2776,6 +2776,23 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif return $this->applyAdvancedSearch(); } public function advancedSearch2Action(): array|ViewModel { if( $this->isAjax() || $this->params()->fromQuery('f') === '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'), ]; $response = new JsonModel($this->getProjectGrantService()->search2($params)); return $response; } return []; } /** * Liste des activités de recherche. */ Loading
module/Oscar/src/Oscar/Service/ProjectGrantService.php +30 −1 Original line number Diff line number Diff line Loading @@ -1202,6 +1202,8 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi $this->getEntityManager()->flush($entity); } protected function debug__displayIds(array $ids) { echo " = "; Loading Loading @@ -2147,6 +2149,26 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi $this->getSearchEngineStrategy()->addActivity($activity); } public function search2(array $params) { /** Construction de la requête **/ $body = []; $result = $this->getSearchEngineStrategy()->searchRaw($params['q'], $limit = 1000, $body); $total = $result['hits']['total']['value']; $datas = []; foreach ($result['hits']['hits'] as $item) { $datas[] = $item['_source']; } return [ 'total' => $total, 'activities' => $datas, 'query' => $body ]; } /** * Retourne les jalons de l'activité. * Loading @@ -2160,7 +2182,14 @@ class ProjectGrantService implements UseGearmanJobLauncherService, UseOscarConfi public function searchIndex_rebuild() { $activities = $this->getEntityManager()->getRepository(Activity::class)->findAll(); //$activities = $this->getEntityManager()->getRepository(Activity::class)->findAll(); $activities = $this->getEntityManager()->getRepository(Activity::class)->findBy( [], ['dateUpdated' => 'DESC'], 10, 0 ); $this->getLoggerService()->info('[elasic] Reindex ' . count($activities) . ' activitie(s)'); return $this->getSearchEngineStrategy()->rebuildIndex($activities); } Loading