Skip to content
Snippets Groups Projects
Commit a0d9cee2 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

hotline #137233 : performance of user page

parent 78cd6d1f
2 merge requests!4098Hotline,!4084hotline #137233 : performance of user page
Pipeline #13819 passed with stage
in 47 minutes and 18 seconds
- ticket #137233 : Espace mon compte : amélioration des performances
\ No newline at end of file
......@@ -25,6 +25,8 @@ class CatalogueLoader extends Storm_Model_Loader {
const DEFAULT_ITEMS_BY_PAGE = 100;
protected $_indexable_cache;
public function loadNoticesFor($catalogue, $itemsByPage = self::DEFAULT_ITEMS_BY_PAGE, $page = 1, $find_all_params = null) {
if (null == $catalogue)
return [];
......@@ -45,8 +47,7 @@ class CatalogueLoader extends Storm_Model_Loader {
public function findAllCataloguesAIndexer() {
return array_filter(Class_Catalogue::findAllBy(['indexer' => true,
'order' => 'libelle']),
return array_filter(Class_Catalogue::findAllIndexable(),
function ($catalogue)
{
return '' != Class_Catalogue::clausesFor($catalogue);
......@@ -54,6 +55,23 @@ class CatalogueLoader extends Storm_Model_Loader {
}
public function findAllIndexableNotEmpty() {
return array_filter(Class_Catalogue::findAllIndexable(),
function($catalog)
{
return !$catalog->isEmpty();
});
}
public function findAllIndexable() {
return $this->_indexable_cache
? $this->_indexable_cache
: $this->_indexable_cache = Class_Catalogue::findAllBy(['indexer' => true,
'order' => 'libelle']);
}
public function getDomainsForBreadcrumb($breadcrumb) {
$domains_ids = array_filter(explode(';', $breadcrumb));
$domains = [];
......@@ -602,7 +620,7 @@ class CatalogueLoader extends Storm_Model_Loader {
public function hasViewableDomain() {
return 0 < count(Class_Catalogue::findAllCataloguesAIndexer());
return 0 < count(Class_Catalogue::findAllIndexableNotEmpty());
}
......
......@@ -54,18 +54,8 @@ class ZendAfi_Form_User_Settings extends ZendAfi_Form {
'library_ids',
['label' => $this->_('Mes bibliothèques préférées'),
'name' => 'library_ids',
'rubrique' => function()
{
$libraries = Class_Profil::getCurrentProfil()->getLibraries();
return (new Class_Entity())
->whenCalledDo('getList', function() use ($libraries)
{
$datas = [];
foreach($libraries as $library)
$datas[$library->getId()] = $library->getLabel();
return $datas;
});
'rubrique' => function() {
return new ZendAfi_Form_User_Settings_LibrariesSource;
},
'selected_all_means_nothing' => false])
......@@ -82,18 +72,8 @@ class ZendAfi_Form_User_Settings extends ZendAfi_Form {
'domain_ids',
['label' => $this->_('Mes thèmes préférés'),
'name' => 'domain_ids',
'rubrique' => function()
{
$domains = Class_Catalogue::findAllCataloguesAIndexer();
return (new Class_Entity())
->whenCalledDo('getList',
function() use ($domains)
{
$datas = [];
foreach($domains as $domain)
$datas[$domain->getId()] = $domain->getLibelle();
return $datas;
});
'rubrique' => function() {
return new ZendAfi_Form_User_Settings_DomainsSource;
},
'selected_all_means_nothing' => false])
......@@ -111,4 +91,28 @@ class ZendAfi_Form_User_Settings extends ZendAfi_Form {
public function setBackUrl($url) {
$this->setAttrib('data-backurl', $url);
}
}
class ZendAfi_Form_User_Settings_LibrariesSource {
public function getList() {
$datas = [];
foreach(Class_Profil::getCurrentProfil()->getLibraries() as $library)
$datas[$library->getId()] = $library->getLabel();
return $datas;
}
}
class ZendAfi_Form_User_Settings_DomainsSource {
public function getList() {
$datas = [];
foreach(Class_Catalogue::findAllIndexableNotEmpty() as $domain)
$datas[$domain->getId()] = $domain->getLibelle();
return $datas;
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment