Fix performance page

This commit is contained in:
Laurent Destailleur 2021-05-27 01:52:52 +02:00
parent 9952fdb6d3
commit 7983ce941e
2 changed files with 100 additions and 8 deletions

View File

@ -464,11 +464,99 @@ if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') {
print '<br>';
}
// Product search
print '<br>';
print '<strong>'.$langs->trans("ComboListOptim").'</strong>: ';
print '<br>';
// Product combo list
$sql = "SELECT COUNT(*) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
$resql = $db->query($sql);
if ($resql) {
$limitforoptim = 5000;
$num = $db->num_rows($resql);
$obj = $db->fetch_object($resql);
$nb = $obj->nb;
if ($nb > $limitforoptim) {
if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
print img_picto('', 'warning.png').' '.$langs->trans("YouHaveXObjectUseComboOptim", $nb, $langs->transnoentitiesnoconv("ProductsOrServices"), 'PRODUIT_USE_SEARCH_TO_SELECT');
} else {
print img_picto('', 'tick.png').' '.$langs->trans("YouHaveXObjectAndSearchOptimOn", $nb, $langs->transnoentitiesnoconv("ProductsOrServices"), 'PRODUIT_USE_SEARCH_TO_SELECT', $conf->global->PRODUIT_USE_SEARCH_TO_SELECT);
}
} else {
print img_picto('', 'tick.png').' '.$langs->trans("NbOfObjectIsLowerThanNoPb", $nb, $langs->transnoentitiesnoconv("ProductsOrServices"));
}
print '<br>';
$db->free($resql);
}
// Thirdparty combo list
$sql = "SELECT COUNT(*) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$resql = $db->query($sql);
if ($resql) {
$limitforoptim = 5000;
$num = $db->num_rows($resql);
$obj = $db->fetch_object($resql);
$nb = $obj->nb;
if ($nb > $limitforoptim) {
if (empty($conf->global->COMPANY_USE_SEARCH_TO_SELECT)) {
print img_picto('', 'warning.png').' '.$langs->trans("YouHaveXObjectUseComboOptim", $nb, $langs->transnoentitiesnoconv("ThirdParties"), 'COMPANY_USE_SEARCH_TO_SELECT');
} else {
print img_picto('', 'tick.png').' '.$langs->trans("YouHaveXObjectAndSearchOptimOn", $nb, $langs->transnoentitiesnoconv("ThirdParties"), 'COMPANY_USE_SEARCH_TO_SELECT', $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
}
} else {
print img_picto('', 'tick.png').' '.$langs->trans("NbOfObjectIsLowerThanNoPb", $nb, $langs->transnoentitiesnoconv("ThirdParties"));
}
print '<br>';
$db->free($resql);
}
// Contact combo list
$sql = "SELECT COUNT(*) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as s";
$resql = $db->query($sql);
if ($resql) {
$limitforoptim = 5000;
$num = $db->num_rows($resql);
$obj = $db->fetch_object($resql);
$nb = $obj->nb;
if ($nb > $limitforoptim) {
if (empty($conf->global->CONTACT_USE_SEARCH_TO_SELECT)) {
print img_picto('', 'warning.png').' '.$langs->trans("YouHaveXObjectUseComboOptim", $nb, $langs->transnoentitiesnoconv("Contacts"), 'CONTACT_USE_SEARCH_TO_SELECT');
} else {
print img_picto('', 'tick.png').' '.$langs->trans("YouHaveXObjectAndSearchOptimOn", $nb, $langs->transnoentitiesnoconv("Contacts"), 'CONTACT_USE_SEARCH_TO_SELECT', $conf->global->CONTACT_USE_SEARCH_TO_SELECT);
}
} else {
print img_picto('', 'tick.png').' '.$langs->trans("NbOfObjectIsLowerThanNoPb", $nb, $langs->transnoentitiesnoconv("Contacts"));
}
print '<br>';
$db->free($resql);
}
// Contact combo list
$sql = "SELECT COUNT(*) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."projet as s";
$resql = $db->query($sql);
if ($resql) {
$limitforoptim = 5000;
$num = $db->num_rows($resql);
$obj = $db->fetch_object($resql);
$nb = $obj->nb;
if ($nb > $limitforoptim) {
if (empty($conf->global->PROJECT_USE_SEARCH_TO_SELECT)) {
print img_picto('', 'warning.png').' '.$langs->trans("YouHaveXObjectUseComboOptim", $nb, $langs->transnoentitiesnoconv("Projects"), 'PROJECT_USE_SEARCH_TO_SELECT');
} else {
print img_picto('', 'tick.png').' '.$langs->trans("YouHaveXObjectAndSearchOptimOn", $nb, $langs->transnoentitiesnoconv("Projects"), 'PROJECT_USE_SEARCH_TO_SELECT', $conf->global->PROJECT_USE_SEARCH_TO_SELECT);
}
} else {
print img_picto('', 'tick.png').' '.$langs->trans("NbOfObjectIsLowerThanNoPb", $nb, $langs->transnoentitiesnoconv("Projects"));
}
print '<br>';
$db->free($resql);
}
print '<br>';
print '<strong>'.$langs->trans("SearchOptim").'</strong>: ';
print '<br>';
$tab = array();
// Product search
$sql = "SELECT COUNT(*) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
$resql = $db->query($sql);
@ -480,8 +568,9 @@ if ($resql) {
if ($nb > $limitforoptim) {
if (empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) {
print img_picto('', 'warning.png').' '.$langs->trans("YouHaveXObjectUseSearchOptim", $nb, $langs->transnoentitiesnoconv("ProductsOrServices"), 'PRODUCT_DONOTSEARCH_ANYWHERE');
print $langs->trans("YouHaveXObjectUseSearchOptimDesc");
} else {
print img_picto('', 'tick.png').' '.$langs->trans("YouHaveXObjectAndSearchOptimOn", $nb, $langs->transnoentitiesnoconv("ProductsOrServices"));
print img_picto('', 'tick.png').' '.$langs->trans("YouHaveXObjectAndSearchOptimOn", $nb, $langs->transnoentitiesnoconv("ProductsOrServices"), 'PRODUCT_DONOTSEARCH_ANYWHERE', $conf->global->PRODUCT_DONOTSEARCH_ANYWHERE);
}
} else {
print img_picto('', 'tick.png').' '.$langs->trans("NbOfObjectIsLowerThanNoPb", $nb, $langs->transnoentitiesnoconv("ProductsOrServices"));
@ -491,20 +580,20 @@ if ($resql) {
}
// Thirdparty search
$tab = array();
$sql = "SELECT COUNT(*) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$resql = $db->query($sql);
if ($resql) {
$limitforoptim = 10000;
$limitforoptim = 100000;
$num = $db->num_rows($resql);
$obj = $db->fetch_object($resql);
$nb = $obj->nb;
if ($nb > $limitforoptim) {
if (empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) {
print img_picto('', 'warning.png').' '.$langs->trans("YouHaveXObjectUseSearchOptim", $nb, $langs->transnoentitiesnoconv("ThirdParties"), 'COMPANY_DONOTSEARCH_ANYWHERE');
print $langs->trans("YouHaveXObjectUseSearchOptimDesc");
} else {
print img_picto('', 'tick.png').' '.$langs->trans("YouHaveXObjectAndSearchOptimOn", $nb, $langs->transnoentitiesnoconv("ThirdParties"));
print img_picto('', 'tick.png').' '.$langs->trans("YouHaveXObjectAndSearchOptimOn", $nb, $langs->transnoentitiesnoconv("ThirdParties"), 'COMPANY_DONOTSEARCH_ANYWHERE', $conf->global->COMPANY_DONOTSEARCH_ANYWHERE);
}
} else {
print img_picto('', 'tick.png').' '.$langs->trans("NbOfObjectIsLowerThanNoPb", $nb, $langs->transnoentitiesnoconv("ThirdParties"));

View File

@ -1323,9 +1323,12 @@ ConditionIsCurrently=Condition is currently %s
YouUseBestDriver=You use driver %s which is the best driver currently available.
YouDoNotUseBestDriver=You use driver %s but driver %s is recommended.
NbOfObjectIsLowerThanNoPb=You have only %s %s in the database. This does not require any particular optimization.
ComboListOptim=Combo list loading optimization
SearchOptim=Search optimization
YouHaveXObjectUseSearchOptim=You have %s %s in the database. You can add the constant %s to 1 in Home-Setup-Other. Limit the search to the beginning of strings which makes it possible for the database to use indexes and you should get an immediate response.
YouHaveXObjectAndSearchOptimOn=You have %s %s in the database and constant %s is set to 1 in Home-Setup-Other.
YouHaveXObjectUseComboOptim=You have %s %s in the database. You can go into setup of module to enable loading of combo list on key pressed event.
YouHaveXObjectUseSearchOptim=You have %s %s in the database. You can add the constant %s to 1 in Home-Setup-Other.
YouHaveXObjectUseSearchOptimDesc=This limits the search to the beginning of strings which makes it possible for the database to use indexes and you should get an immediate response.
YouHaveXObjectAndSearchOptimOn=You have %s %s in the database and constant %s is set to %s in Home-Setup-Other.
BrowserIsOK=You are using the %s web browser. This browser is ok for security and performance.
BrowserIsKO=You are using the %s web browser. This browser is known to be a bad choice for security, performance and reliability. We recommend using Firefox, Chrome, Opera or Safari.
PHPModuleLoaded=PHP component %s is loaded