From e3c741eb3ef184f29d890365176de6b6c0b9c675 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki <arthur.suzuki@biblibre.com> Date: Tue, 16 Jun 2020 14:44:11 +0200 Subject: [PATCH] hotline#89458: added a script to remove unused interests --- VERSIONS_HOTLINE/89458 | 1 + scripts/clean_unused_interest.php | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 VERSIONS_HOTLINE/89458 create mode 100644 scripts/clean_unused_interest.php diff --git a/VERSIONS_HOTLINE/89458 b/VERSIONS_HOTLINE/89458 new file mode 100644 index 00000000000..e2616c31cc5 --- /dev/null +++ b/VERSIONS_HOTLINE/89458 @@ -0,0 +1 @@ + - ticket #89458 : Ajout d'un script de suppression des centres d'interets devenus inutiles \ No newline at end of file diff --git a/scripts/clean_unused_interest.php b/scripts/clean_unused_interest.php new file mode 100644 index 00000000000..9a019da83b7 --- /dev/null +++ b/scripts/clean_unused_interest.php @@ -0,0 +1,27 @@ +<?php +error_reporting(E_ERROR | E_PARSE); +require(__DIR__.'/../console.php'); + +echo "\n\nWelcome\n\n"; + +$matching = []; + +Class Script_Interet_Cleaner { + public function findAllInteretWithoutNotices () { + echo 'nombre de centre d\'interet:' . count(Class_CodifCentreInteret::findAll()); + return array_filter(Class_CodifCentreInteret::findAll(), + function($codif) { + return (!Class_Notice::findFirstBy(['where' => 'match(facettes) against(\'F' . $codif->getId() . '\')'])); + }); + } +} + +$script = new Script_Interet_Cleaner(); + +array_map( + function($codif) { + echo "delete ".$codif->getLibelle()."\n"; + $codif->delete(); + }, + $script->findAllInteretWithoutNotices()); +echo "\n\nDONE !!!!\n\n"; -- GitLab