r494@llin: dpavlin | 2006-02-27 00:22:59 +0100
[webpac2] / run.pl
diff --git a/run.pl b/run.pl
index 4f99408..7a833f5 100755 (executable)
--- a/run.pl
+++ b/run.pl
@@ -13,10 +13,11 @@ use WebPAC::Input 0.03;
 use WebPAC::Store 0.03;
 use WebPAC::Normalize::XML;
 use WebPAC::Output::TT;
-use WebPAC::Output::Estraier 0.08;
+use WebPAC::Output::Estraier '0.10';
 use YAML qw/LoadFile/;
 use Getopt::Long;
 use File::Path;
+use Time::HiRes qw/time/;
 
 =head1 NAME
 
@@ -40,6 +41,10 @@ limit loading to 100 records
 
 remove database and Hyper Estraier index before indexing
 
+=item --one=database_name
+
+reindex just single database
+
 =item --config conf/config.yml
 
 path to YAML configuration file
@@ -54,11 +59,13 @@ my $limit;
 my $clean = 0;
 my $config = 'conf/config.yml';
 my $debug = 0;
+my $one_db_name;
 
 GetOptions(
        "limit=i" => \$limit,
        "offset=i" => \$offset,
        "clean" => \$clean,
+       "one=s" => \$one_db_name,
        "config" => \$config,
        "debug" => \$debug,
 );
@@ -70,9 +77,12 @@ print "config = ",Dumper($config) if ($debug);
 die "no databases in config file!\n" unless ($config->{databases});
 
 my $total_rows = 0;
+my $start_t = time();
 
 while (my ($database, $db_config) = each %{ $config->{databases} }) {
 
+       next if ($one_db_name && $database !~ m/$one_db_name/i);
+
        my $log = _new WebPAC::Common()->_get_logger();
 
        #
@@ -82,6 +92,7 @@ while (my ($database, $db_config) = each %{ $config->{databases} }) {
        my $est_config = $config->{hyperestraier} || $log->logdie("can't find 'hyperestraier' part in confguration");
        $est_config->{database} = $database;
        $est_config->{clean} = $clean;
+       $est_config->{label} = $db_config->{name};
 
        my $est = new WebPAC::Output::Estraier( %{ $est_config } );
 
@@ -97,7 +108,7 @@ while (my ($database, $db_config) = each %{ $config->{databases} }) {
                $log->info("creating new database $database in $db_path");
                rmtree( $db_path ) || $log->warn("can't remove $db_path: $!");
        } else {
-               $log->info("working on $database in $db_path");
+               $log->debug("working on $database in $db_path");
        }
 
        my $db = new WebPAC::Store(
@@ -134,7 +145,7 @@ while (my ($database, $db_config) = each %{ $config->{databases} }) {
 
                my $input_module = $config->{webpac}->{inputs}->{$type};
 
-               $log->info("working on input $input->{path} [$input->{type}] using $input_module");
+               $log->info("working on input '$input->{path}' [$input->{type}] using $input_module lookup '$input->{lookup}'");
 
                my $input_db = new WebPAC::Input(
                        module => $input_module,
@@ -142,6 +153,7 @@ while (my ($database, $db_config) = each %{ $config->{databases} }) {
                        limit => $limit || $input->{limit},
                        offset => $offset,
                        lookup => $lookup,
+                       recode => $input->{recode},
                );
                $log->logdie("can't create input using $input_module") unless ($input);
 
@@ -197,7 +209,12 @@ while (my ($database, $db_config) = each %{ $config->{databases} }) {
 
        };
 
-       $log->info("$total_rows records indexed");
+       my $dt = time() - $start_t;
+       $log->info("$total_rows records indexed in " .
+               sprintf("%.2f sec [%.2f rec/sec]",
+                       $dt, ($total_rows / $dt)
+               )
+       );
 
        #
        # add Hyper Estraier links to other databases