diff --git a/VERSIONS b/VERSIONS index f3ecb13e66d917b88d4452059abb8213dcf48c1f..179fd3b2e13d7c58e725891829d5ce39be4d05d6 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,3 +1,12 @@ + + - ticket #43155 : Intégrations: amélioration de la gestion des erreurs pendant l'éxécution des batchs + + - ticket #51096 : Désactivation du moissonnage total de Jamendo (trop de notices). L'import manuel d'album reste activé. + + - ticket #50888 : Administration : correction des statistiques de recherches infructueuses + + + 23/11/2016 - v7.7.18 - ticket #50500 : Indexation : correction d'une erreur lorsqu'un niveau thesaurus dépassait 9999 éléments diff --git a/VERSIONS_HOTLINE/43155 b/VERSIONS_HOTLINE/43155 deleted file mode 100644 index d5150ddfa30cffa22f83936065c840bfea3b3fef..0000000000000000000000000000000000000000 --- a/VERSIONS_HOTLINE/43155 +++ /dev/null @@ -1 +0,0 @@ - - ticket #43155 : Intégrations: amélioration de la gestion des erreurs pendant l'éxécution des batchs \ No newline at end of file diff --git a/VERSIONS_HOTLINE/51096 b/VERSIONS_HOTLINE/51096 deleted file mode 100644 index eef6b4cd26b1746616807618aa542247cbb6f568..0000000000000000000000000000000000000000 --- a/VERSIONS_HOTLINE/51096 +++ /dev/null @@ -1 +0,0 @@ - - ticket #51096 : désactivation du moissonnage total de Jamendo (trop de notices). L'import manuel d'album reste activé. \ No newline at end of file diff --git a/application/modules/admin/controllers/StatController.php b/application/modules/admin/controllers/StatController.php index 60ac69d23645b92315408e29b8ee856a771fd40c..41f49ba29c1ebe0edc79d1c368785e4e8837a28f 100644 --- a/application/modules/admin/controllers/StatController.php +++ b/application/modules/admin/controllers/StatController.php @@ -41,12 +41,10 @@ class Admin_StatController extends ZendAfi_Controller_Action { public function rechercheinfructueuseAction() { $this->view->titre = $this->_('Recherches infructueuses'); - $page = $this->_getParam('page', 1); - $this->view->nb_par_page = 20; - $start = ($page-1) * $this->view->nb_par_page; + $this->view->page = $page = $this->_getParam('page', 1); + $this->view->nb_par_page = 100; $this->view->liste = $this->cls_stat->getNotFoundByPage($page, $this->view->nb_par_page); $this->view->nombre_total = $this->cls_stat->getTotalNotFound(); - $this->view->page = $page; } diff --git a/application/modules/admin/views/scripts/stat/rechercheinfructueuse.phtml b/application/modules/admin/views/scripts/stat/rechercheinfructueuse.phtml index e63e99bb28240ada3c19872358e34b5c29b7ff5f..8bf7b101150779f90d9d8ef6198fb1ce8148c1a8 100644 --- a/application/modules/admin/views/scripts/stat/rechercheinfructueuse.phtml +++ b/application/modules/admin/views/scripts/stat/rechercheinfructueuse.phtml @@ -1,41 +1,29 @@ -<?php -print('<link rel="stylesheet" type="text/css" media="screen" href="'.URL_ADMIN_CSS.'statistique.css" />'); -print('<h4>Nombre de recherches infructueuses : '.$this->nombre_total.'</h4>'); +<?php +$paginator = $this->paginationControl((new Zend_Paginator(new Zend_Paginator_Adapter_Null($this->nombre_total))) + ->setItemCountPerPage($this->nb_par_page) + ->setCurrentPageNumber($this->page)); -// Entete -print('<table class="stat" style="width:740px" border="0">'); -print('<tr>'); -print('<th class="stat">Date</th>'); -print('<th class="stat">Recherche</th>'); -print('</tr>'); +echo $this->tag('h4', $this->_('Nombre de recherches infructueuse : %s', $this->nombre_total)) + . $paginator + . $this->tagModelTable($this->liste, + [$this->_('Date'), + $this->_('Critères')], + ['date_recherche', + 'criteres'], + [], + 'empty_results', + null, + ['date_recherche' => function($model) + { + return Class_Date::getHumanDate($model->getDateRecherche(), 'd MMMM yyyy'); + }, + 'criteres' => function($model) + { + if(!$crit = unserialize(stripslashes($model->getCriteres()))) + return $model->getCriteres(); -$codification = new Class_Codification(); - -// Lignes -foreach($this->liste as $ligne) -{ - $expression=""; - $criteres=""; - $crit=""; - $date=substr($ligne["date_recherche"],8,2).substr($ligne["date_recherche"],4,4).substr($ligne["date_recherche"],0,4); - try { - if (!$crit = ZendAfi_Filters_Serialize::unserialize($ligne["criteres"])) - $crit = []; - } catch (Exception $e) { - $crit = []; - } - - $criteres = $this->tagHistoriqueRecherche((new Class_CriteresRecherche())->setParams($crit)); - - print('<tr>'); - print('<td valign="top" style="text-align:center">'.$date.'</td>'); - print('<td valign="top">'.$criteres.'</td>'); - print('</tr>'); -} - -// Fini -print('</table>'); -$pager=$this->Pager($this->nombre_total,$this->nb_par_page,$this->page,BASE_URL."/admin/stat/rechercheinfructueuse"); -print('<div style="width:740px"><center>'.$pager.'</div>'); - -?> + return $this->tagHistoriqueRecherche((new Class_CriteresRecherche())->setParams($crit)); + } + ]) + . $paginator; +?> \ No newline at end of file diff --git a/library/Class/Codification.php b/library/Class/Codification.php index adf46e4519da031c0e1b49282c638cbf18846308..125ad6f95dca5af28d37ceee7a2f98ca0208ee95 100644 --- a/library/Class/Codification.php +++ b/library/Class/Codification.php @@ -255,6 +255,9 @@ class Class_Codification { public static function getLibelleForSerie($notice) { + if(!$notice) + return ''; + $message = 'Voir tous les tomes'; switch ($notice->getTypeDoc()) { diff --git a/library/Class/MoteurRecherche.php b/library/Class/MoteurRecherche.php index f5b6d3813bc03f00b9b08907e814bbb80633c91d..646a23b2479d9dc23ec5dc0b995871c775a38ce3 100644 --- a/library/Class/MoteurRecherche.php +++ b/library/Class/MoteurRecherche.php @@ -474,7 +474,7 @@ class Class_MoteurRecherche { $nb = $search_result->getRecordsCount(); if (!$nb && !$this->_shouldExtend()) { - $this->addStatEchec(2, $criteres_recherche->getCriteres()); + $this->addStatEchec($criteres_recherche->getCriteres()); return $search_result->beError($this->_('Aucun résultat trouvé')); } @@ -626,9 +626,17 @@ class Class_MoteurRecherche { } - private function addStatEchec($type_recherche,$criteres) { + protected function addStatEchec($criteres) { + $excluded_keys = ['retour_panier', + 'retour_abonne', + 'retour_avis']; + + if(array_intersect($excluded_keys, + array_keys($criteres))) + return; + (new Class_StatRechercheEchec()) - ->setTypeRecherche($type_recherche) + ->setTypeRecherche(2) // ??? ->setCriteres(addslashes(serialize($criteres))) ->save(); } diff --git a/library/Class/StatsNotices.php b/library/Class/StatsNotices.php index 68e8cfc646e87ac0e4b279c69495d6d765caf20b..fd3da49089447def94dda15461f4c3504f835439 100644 --- a/library/Class/StatsNotices.php +++ b/library/Class/StatsNotices.php @@ -164,11 +164,14 @@ class Class_StatsNotices { public function getTotalNotFound() { - return fetchOne('select count(*) from stats_recherche_echec'); + return Class_StatRechercheEchec::count(); } public function getNotFoundByPage($start, $count) { + return Class_StatRechercheEchec::findAllBy(['order' => 'id desc' , + 'limitPage' => [$start, $count]]); + return fetchAll(sprintf('select * from stats_recherche_echec order by id desc limit %s, %s', $start, $count)); } diff --git a/tests/application/modules/admin/controllers/StatControllerTest.php b/tests/application/modules/admin/controllers/StatControllerTest.php index f680b9f0550e9a5b708a6be2bb5dbb1162ba426b..bfa2d5ef9132132ff982f5c98ce7831786409232 100644 --- a/tests/application/modules/admin/controllers/StatControllerTest.php +++ b/tests/application/modules/admin/controllers/StatControllerTest.php @@ -21,14 +21,47 @@ require_once 'AdminAbstractControllerTestCase.php'; class Admin_StatControllerRecherchesInfructueusesTest extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); + + $this->fixture('Class_StatRechercheEchec', + ['id' => 1, + 'date_recherche' => '', + 'criteres' => serialize(['expressionRecherche' => 'not found', + 'tri' => '*'])]); + + $this->fixture('Class_StatRechercheEchec', + ['id' => 2, + 'date_recherche' => '', + 'criteres' => 'a:6:{s:11:\"rech_titres\";s:44:\"l\'idée ridicule de ne plus jamais te revoir\";s:12:\"rech_auteurs\";s:12:\"rosa montero\";s:3:\"tri\";s:1:\"*\";s:16:\"operateur_titres\";s:3:\"and\";s:17:\"operateur_auteurs\";s:3:\"and\";s:14:\"type_recherche\";s:8:\"fulltext\";}']); + $this->dispatch('/admin/stat/rechercheinfructueuse', true); } + /** @test */ public function titreShouldBeRecherchesInfructueuses() { $this->assertXPathContentContains('//h1', 'Recherches infructueuses'); } + + + /** @test */ + public function tdShouldContainsNotFound() { + $this->assertXpathContentContains('//td', 'not found'); + } + + + /** @test */ + public function tdShouldContainsLIdeeRidicule() { + $this->assertXpathContentContains('//td', 'l\'idée ridicule de ne plus jamais te revoir'); + } + + + /** @test */ + public function totalCountShouldBe2() { + $this->assertXPathContentContains('//h4', 'Nombre de recherches infructueuse : 2'); + } } ?> \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/RechercheControllerTest.php b/tests/application/modules/opac/controllers/RechercheControllerTest.php index 1589e4ebee5753fb6e0d6226182b3e0871c7f8a6..bdcd45d9bd9578424bfef618f896618df157d179 100644 --- a/tests/application/modules/opac/controllers/RechercheControllerTest.php +++ b/tests/application/modules/opac/controllers/RechercheControllerTest.php @@ -3049,7 +3049,9 @@ class RechercheControllerViewnoticeWithBreadcrumbAndIdPanierParamTest extends Re -class RechercheControlleSimpleActionWithEmptyDomainSettingsTest extends AbstractControllerTestCase { +class RechercheControllerSimpleActionWithEmptyDomainSettingsTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); @@ -3057,19 +3059,55 @@ class RechercheControlleSimpleActionWithEmptyDomainSettingsTest extends Abstract ['id'=>3, 'libelle' => 'Nouveautés', 'auteur' => 'Paul']); + $this->dispatch('/recherche/simple/id_catalogue/3/id_module/9/aleatoire/1', true); } /** @test */ public function onRechercheSimpleCatalogue3IdModule9ResultsShouldBeEmpty() { - $this->assertXPathContentContains('//div[@class="info-recherche"]', 'Aucun résultat trouvé', $this->_response->getBody()); + $this->assertXPathContentContains('//div[@class="info-recherche"]', + 'Aucun résultat trouvé', + $this->_response->getBody()); + } + + + /** @test */ + public function statRechercheEchecShouldHaveBeenCreated() { + $this->assertNotEmpty(Class_StatRechercheEchec::findAll()); + } +} + + + + +class RechercheControllerNoResultOnSubscriberLinkTest extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + $this->dispatch('/recherche/simple/retour_abonne/viewavis/retour_avis/8/page/2/id_module/8/code_rebond/G1', true); + } + + + /** @test */ + public function noResultMesssageShouldBeDisplay() { + $this->assertXPathContentContains('//div[@class="resultat_recherche"]', + 'Aucun résultat trouvé', + $this->_response->getBody()); + } + + + /** @test */ + public function statRechercheEchecShouldNotHaveBeenCreated() { + $this->assertEmpty(Class_StatRechercheEchec::findAll()); } } -class RechercheControlleSimpleActionWithEmptyDomainSettingsAndSiteLinkedTest extends RechercheControllerNoticeTestCase { + +class RechercheControllerSimpleActionWithEmptyDomainSettingsAndSiteLinkedTest extends RechercheControllerNoticeTestCase { public function setUp() { parent::setUp(); $this->fixture('Class_Catalogue',