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

rel #21691 : only handles diffs when reindexing domains, only update linked...

rel #21691 : only handles diffs when reindexing domains, only update linked record facets instead of update all domain's records
parent 9ec1750a
Branches
Tags
4 merge requests!780Master,!722Master,!721Hotline master,!718Hotline#21691 articles indexall performance
- ticket #21691 : Optimisation de la performance de la réindexation des données dans les domaines
\ No newline at end of file
......@@ -53,14 +53,18 @@ if ($phase==15) {
$phase_data["pointeur"]=0;
}
$log->ecrire('<h4>Indexation des paniers dans les domaines</h4>');
Class_PanierNotice::indexAll();
if ($mode_cron) {
$log->ecrire('<h4>Indexation des paniers dans les domaines</h4>');
Class_PanierNotice::indexAll();
$log->ecrire("<h4>Indexation des articles dans les domaines</h4>");
Class_Article::indexAll();
$log->ecrire("<h4>Indexation des articles dans les domaines</h4>");
Class_Article::indexAll();
$log->ecrire("<h4>Indexation des sitothèques dans les domaines</h4>");
Class_Sitotheque::indexAll();
$log->ecrire("<h4>Indexation des sitothèques dans les domaines</h4>");
Class_Sitotheque::indexAll();
} else {
$log->ecrire("<h4>Les indexations des paniers, articles et sitothèques dans les domaines ne sont traitées qu'en mode cron</h4>");
}
}
?>
......@@ -161,5 +161,13 @@ class Class_NoticeDomain extends Storm_Model_Abstract {
public function getNotice() {
return Class_Notice::findFirstBy(['clef_alpha' => $this->getRecordAlphaKey()]);
}
public function updateFacette() {
$this->getNotice()
->updateFacette($this->getDomain()->getFacette())
->save();
return $this;
}
}
?>
\ No newline at end of file
......@@ -37,14 +37,18 @@ trait Trait_Indexable {
return $this;
}
Class_NoticeDomain::deleteBy(['record_alpha_key' => $alpha_key]);
$existing = Class_NoticeDomain::findAllBy(['record_alpha_key' => $alpha_key]);
$existing_ids = array_map(function ($item) { return $item->getDomainId();}, $existing);
foreach($domains_ids as $domain_id) {
Class_NoticeDomain::newInstance(['domain_id' => $domain_id,
'record_alpha_key' => $alpha_key])
->save();
if ($to_delete = array_diff($existing_ids, $domains_ids))
Class_NoticeDomain::deleteBy(['record_alpha_key' => $alpha_key,
'domain_id' => $to_delete]);
Class_NoticeDomain::updateRecordsFacette($domain_id);
foreach(array_diff($domains_ids, $existing_ids) as $domain_id) {
$notice_domain = Class_NoticeDomain::newInstance(['domain_id' => $domain_id,
'record_alpha_key' => $alpha_key]);
$notice_domain->save();
$notice_domain->updateFacette();
}
return $this;
......
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