improved cleanflaglist script

This commit is contained in:
Bachir Soussi Chiadmi 2022-10-18 15:03:32 +02:00
parent 4bc00f9b2b
commit 1beb2b4dfa
1 changed files with 25 additions and 8 deletions

View File

@ -7,14 +7,31 @@
use Drush\Drush;
$this->output()->writeln("Flagging collection cleaning");
$this->output()->writeln("options : [delete-all | delete-nullname | delete-missing | delete-dups]");
// $this->output()->writeln("Hello world!");
$this->output()->writeln("The extra options/arguments to this command were:");
$this->output()->writeln(print_r($extra, true));
if ($extra[0] === "delete") {
$delete = true;
} else {
$delete = false;
$delete_all = fasle;
$delete_nullname = false;
$delete_missing = false;
$delete_dups = false;
if ($extra[0] === "delete-all") {
$delete_all = true;
}
if ($extra[0] === "delete-missing") {
$delete_missing = true;
}
if ($extra[0] === "delete-nullname") {
$delete_nullname = true;
}
if ($extra[0] === "delete-dups") {
$delete_dups = true;
}
@ -43,7 +60,7 @@ foreach ($fcfd_result as $fc) {
$this->output()->writeln($flifd_query->countQuery()->execute()->fetchField() . " items for fc " . $fc->id . ' with baseflag ' . $fc->relatedflag);
// $this->output()->writeln(print_r($flifd_result->fetchAssoc(), true) . " items");
delete_flagingcollection($fc, $database, $delete);
delete_flagingcollection($fc, $database, $delete_all ? true : $delete_nullname);
}
@ -64,9 +81,9 @@ foreach ($fcfd_result as $fc) {
$conf_result = $flag_query->execute();
$count = $flag_query->countQuery()->execute()->fetchField();
if(!$count){
$this->output()->writeln($fc->id . ' flagging_collection has ' . $count . " relatedflag");
$this->output()->writeln(' flagging_collection' . $fc->id . ' has ' . $count . " relatedflag");
$fc_missing_relatedflag ++;
delete_flagingcollection($fc, $database, $delete);
delete_flagingcollection($fc, $database, $delete_all ? true : $delete_missing);
}
}
$this->output()->writeln($fc_missing_relatedflag .' flagging_collection with missing related_flag');
@ -96,7 +113,7 @@ foreach ($dup_result as $dup){
$this->output()->writeln($dup->relatedflag . ' relatedflag has ' . $count . ' flagging collection');
foreach ($fcfd_result as $fc) {
delete_flagingcollection($fc, $database, $delete);
delete_flagingcollection($fc, $database, $delete_all ? true : $delete_dups);
}
}