mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
(Retrofit from trunk) Portal : Optimized column load in ManageBrick and BrowseBrick to improve performances
SVN:2.3[4407]
This commit is contained in:
@@ -259,7 +259,29 @@ class BrowseBrickController extends BrickController
|
|||||||
{
|
{
|
||||||
$oSet = new DBObjectSet($oQuery);
|
$oSet = new DBObjectSet($oQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optimizing the ObjectSet to retrieve only necessary columns
|
||||||
|
$aColumnAttrs = array();
|
||||||
|
foreach ($oSet->GetFilter()->GetSelectedClasses() as $sTmpClassAlias => $sTmpClassName)
|
||||||
|
{
|
||||||
|
if (isset($aLevelsProperties[$sTmpClassAlias]))
|
||||||
|
{
|
||||||
|
$aTmpLevelProperties = $aLevelsProperties[$sTmpClassAlias];
|
||||||
|
// Mandatory main attribute
|
||||||
|
$aTmpColumnAttrs = array($aTmpLevelProperties['name_att']);
|
||||||
|
// Optionnal attributes, only if in list mode
|
||||||
|
if ($sBrowseMode === BrowseBrick::ENUM_BROWSE_MODE_LIST)
|
||||||
|
{
|
||||||
|
foreach ($aTmpLevelProperties['fields'] as $aTmpField)
|
||||||
|
{
|
||||||
|
$aTmpColumnAttrs[] = $aTmpField['code'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$aColumnAttrs[$sTmpClassAlias] = $aTmpColumnAttrs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$oSet->OptimizeColumnLoad($aColumnAttrs);
|
||||||
|
|
||||||
// Retrieving results and organizing them for templating
|
// Retrieving results and organizing them for templating
|
||||||
$aItems = array();
|
$aItems = array();
|
||||||
while ($aCurrentRow = $oSet->FetchAssoc())
|
while ($aCurrentRow = $oSet->FetchAssoc())
|
||||||
|
|||||||
@@ -59,6 +59,15 @@ class ManageBrickController extends BrickController
|
|||||||
// Getting search value
|
// Getting search value
|
||||||
$sSearchValue = $oRequest->get('sSearchValue', null);
|
$sSearchValue = $oRequest->get('sSearchValue', null);
|
||||||
|
|
||||||
|
// Getting area columns properties
|
||||||
|
$aColumnsAttrs = $oBrick->GetFields();
|
||||||
|
// Adding friendlyname attribute to the list is not already in it
|
||||||
|
$sTitleAttrCode = 'friendlyname';
|
||||||
|
if (($sTitleAttrCode !== null) && !in_array($sTitleAttrCode, $aColumnsAttrs))
|
||||||
|
{
|
||||||
|
$aColumnsAttrs = array_merge(array($sTitleAttrCode), $aColumnsAttrs);
|
||||||
|
}
|
||||||
|
|
||||||
// Starting to build query
|
// Starting to build query
|
||||||
$oQuery = DBSearch::FromOQL($oBrick->GetOql());
|
$oQuery = DBSearch::FromOQL($oBrick->GetOql());
|
||||||
|
|
||||||
@@ -264,6 +273,7 @@ class ManageBrickController extends BrickController
|
|||||||
// - Check how many records there is.
|
// - Check how many records there is.
|
||||||
// - Update $sDataLoading with its new value regarding the number of record and the threshold
|
// - Update $sDataLoading with its new value regarding the number of record and the threshold
|
||||||
$oCountSet = new DBObjectSet($oQuery);
|
$oCountSet = new DBObjectSet($oQuery);
|
||||||
|
$oCountSet->OptimizeColumnLoad(array($oQuery->GetClassAlias() => $aColumnsAttrs));
|
||||||
$fThreshold = (float) MetaModel::GetModuleSetting($oApp['combodo.portal.instance.id'], 'lazy_loading_threshold');
|
$fThreshold = (float) MetaModel::GetModuleSetting($oApp['combodo.portal.instance.id'], 'lazy_loading_threshold');
|
||||||
$sDataLoading = ($oCountSet->Count() > $fThreshold) ? AbstractBrick::ENUM_DATA_LOADING_LAZY : AbstractBrick::ENUM_DATA_LOADING_FULL;
|
$sDataLoading = ($oCountSet->Count() > $fThreshold) ? AbstractBrick::ENUM_DATA_LOADING_LAZY : AbstractBrick::ENUM_DATA_LOADING_FULL;
|
||||||
unset($oCountSet);
|
unset($oCountSet);
|
||||||
@@ -285,6 +295,7 @@ class ManageBrickController extends BrickController
|
|||||||
|
|
||||||
// Getting total records number
|
// Getting total records number
|
||||||
$oCountSet = new DBObjectSet($oQuery);
|
$oCountSet = new DBObjectSet($oQuery);
|
||||||
|
$oCountSet->OptimizeColumnLoad(array($oQuery->GetClassAlias() => $aColumnsAttrs));
|
||||||
$aData['recordsTotal'] = $oCountSet->Count();
|
$aData['recordsTotal'] = $oCountSet->Count();
|
||||||
$aData['recordsFiltered'] = $oCountSet->Count();
|
$aData['recordsFiltered'] = $oCountSet->Count();
|
||||||
unset($oCountSet);
|
unset($oCountSet);
|
||||||
@@ -296,6 +307,7 @@ class ManageBrickController extends BrickController
|
|||||||
{
|
{
|
||||||
$oSet = new DBObjectSet($oQuery);
|
$oSet = new DBObjectSet($oQuery);
|
||||||
}
|
}
|
||||||
|
$oSet->OptimizeColumnLoad(array($oQuery->GetClassAlias() => $aColumnsAttrs));
|
||||||
$aSets[$sKey] = $oSet;
|
$aSets[$sKey] = $oSet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -306,15 +318,7 @@ class ManageBrickController extends BrickController
|
|||||||
{
|
{
|
||||||
// Set properties
|
// Set properties
|
||||||
$sCurrentClass = $sKey;
|
$sCurrentClass = $sKey;
|
||||||
$sTitleAttrCode = 'friendlyname';
|
|
||||||
|
|
||||||
// Getting area columns properties
|
|
||||||
$aColumnsAttrs = $oBrick->GetFields();
|
|
||||||
// Adding friendlyname attribute to the list is not already in it
|
|
||||||
if (($sTitleAttrCode !== null) && !in_array($sTitleAttrCode, $aColumnsAttrs))
|
|
||||||
{
|
|
||||||
$aColumnsAttrs = array_merge(array($sTitleAttrCode), $aColumnsAttrs);
|
|
||||||
}
|
|
||||||
// Defining which attribute will open the edition form)
|
// Defining which attribute will open the edition form)
|
||||||
$sMainActionAttrCode = $aColumnsAttrs[0];
|
$sMainActionAttrCode = $aColumnsAttrs[0];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user