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

Merge branch 'hotline#93469_aucun_resultat_sur_un_motclef_tess' into 'hotline'

hotline #93469 : add dynamic facets cleaner

See merge request !3164
parents 3c02fc5a 2d28db6e
Branches
Tags
4 merge requests!3297WIP: Master,!3168Master,!3167Hotline,!3164hotline #93469 : add dynamic facets cleaner
Pipeline #7619 passed with stage
in 1 hour, 9 minutes, and 7 seconds
- ticket #93469 : Indexation : Ajout d'un script de nettoyage des facettes dynamiques obsolètes
\ No newline at end of file
<?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
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