diff --git a/VERSIONS_HOTLINE/93469 b/VERSIONS_HOTLINE/93469 new file mode 100644 index 0000000000000000000000000000000000000000..f3d344312fc29841190e5eac164ecccdaed91107 --- /dev/null +++ b/VERSIONS_HOTLINE/93469 @@ -0,0 +1 @@ + - ticket #93469 : Indexation : Ajout d'un script de nettoyage des facettes dynamiques obsolètes \ No newline at end of file diff --git a/scripts/clean_local_dymanic_facets.php b/scripts/clean_local_dymanic_facets.php new file mode 100644 index 0000000000000000000000000000000000000000..a4276595903a9e37d10a97e55d3a0971ef033259 --- /dev/null +++ b/scripts/clean_local_dymanic_facets.php @@ -0,0 +1,43 @@ +<?php +error_reporting(E_ERROR | E_PARSE); +require(__DIR__.'/../console.php'); + +echo "\n\nWelcome to the iFacetsCleaner Platinum tool by @patbator\n\n"; + +class Scripts_Local_DynamicFacets_Cleaner { + + public function clean($record) { + $existing = array_filter(explode(' ', $record->getFacettes())); + foreach($existing as $facet) + $is_hmot = $is_hmot || 'MOTC' == substr($facet, 1, 4); + + if (!$is_hmot) + return; + + echo '.'; + + $facets = []; + foreach($existing as $facet) { + if ((Class_CodifThesaurus::CODE_FACETTE != substr($facet, 0, 1)) + || (1 == Class_CodifThesaurus::countBy(['id_thesaurus' => substr($facet, 1)]))) + $facets[] = $facet; + } + + $record->setFacettes($facets); + $record->save(); + } +} + +$cleaner = new Scripts_Local_DynamicFacets_Cleaner(); +$page = 1; +while ($records = Class_Notice::findAllBy(['type' => Class_Notice::TYPE_BIBLIOGRAPHIC, + 'limitPage' => [$page, 1000]])) { + echo "\npage: $page\n"; + $page ++; + array_map([$cleaner, 'clean'], $records); + Storm_Model_Abstract::unsetLoaders(); + Storm_Model_Loader::resetCache(); + gc_collect_cycles(); +} + +echo "\n\nDONE !!!!\n\n"; \ No newline at end of file