ffzg/recall_notices.pl: added --interval and --dedup
[koha.git] / misc / migration_tools / remove_unused_authorities.pl
index eec2155..f4e0ecb 100755 (executable)
@@ -27,6 +27,8 @@ use C4::Context;
 use C4::AuthoritiesMarc;
 use Getopt::Long;
 
+use Koha::SearchEngine::Search;
+
 my @authtypes;
 my $want_help = 0;
 my $test = 0;
@@ -66,11 +68,12 @@ $rqselect->execute;
 my $counter=0;
 my $totdeleted=0;
 my $totundeleted=0;
+my $searcher = Koha::SearchEngine::Search->new({index => 'biblios'});
 while (my $data=$rqselect->fetchrow_hashref){
     my $query;
     $query= "an=".$data->{'authid'};
     # search for biblios mapped
-    my ($err,$res,$used) = C4::Search::SimpleSearch($query,0,10);
+    my ($err,$res,$used) = $searcher->simple_search_compat($query,0,10);
     if (defined $err) {
         warn "error: $err on search $query\n";
         next;
@@ -79,7 +82,7 @@ while (my $data=$rqselect->fetchrow_hashref){
     print "$counter\n" unless $counter++ % 100;
     # if found, delete, otherwise, just count
     if ($used>=$thresholdmin and $used<=$thresholdmax){
-        DelAuthority($data->{'authid'}) unless $test;
+        DelAuthority({ authid => $data->{'authid'} }) unless $test;
         $totdeleted++;
     } else {
         $totundeleted++;