r9064@llin: dpavlin | 2005-11-23 01:15:24 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 23 Nov 2005 00:14:05 +0000 (00:14 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 23 Nov 2005 00:14:05 +0000 (00:14 +0000)
 minor tweak for database routines, run.pl now iterates through all entries
 (to fix problem with stopping at first deleted entry)

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@113 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/DB.pm
lib/WebPAC/Input/ISIS.pm
lib/WebPAC/Output/Estraier.pm
run.pl

index bda66cc..f9e58e0 100644 (file)
@@ -198,8 +198,11 @@ sub save_ds {
 
        $log->logdie("save_ds without cache_file -- did you called gs_get before?") unless ($self->{'cache_file'});
 
-       foreach my $e (qw/ds current_filename headline/) {
-               $log->warn("missing $e") unless $arg->{$e};
+       $log->logdie("need ds") unless ($arg->{ds});
+
+       foreach my $e (qw/current_filename headline/) {
+               my $mfn = $arg->{ds}->{000}->[0] || '?';
+               $log->warn("missing $e in record $mfn") unless $arg->{$e};
        }
 
        $log->debug("creating storable cache file ",$self->{'cache_file'});
index b6a05f3..5ab2a76 100644 (file)
@@ -181,7 +181,10 @@ sub open {
                        $log->logdie("hum? implementation missing?");
                }
 
-               $log->confess("record $mfn empty?") unless ($rec);
+               if (! $rec) {
+                       $log->warn("record $mfn empty? skipping...");
+                       next;
+               }
 
                # store
                if ($self->{'low_mem'}) {
@@ -242,11 +245,15 @@ sub fetch {
 
        $self->progress_bar($mfn,$self->{'max_mfn'});
 
+       my $rec;
+
        if ($self->{'low_mem'}) {
-               return $self->{'db'}->get($mfn);
+               $rec = $self->{'db'}->get($mfn);
        } else {
-               return $self->{'data'}->{$mfn};
+               $rec = $self->{'data'}->{$mfn};
        }
+
+       $rec ||= 0E0;
 }
 
 =head2 pos
index 5581abc..871237f 100644 (file)
@@ -146,7 +146,7 @@ sub add {
 
        # filter all tags which have type defined
        my @tags = grep {
-               defined( $args->{'ds'}->{$_}->{$type} )
+               ref($args->{'ds'}->{$_}) eq 'HASH' && defined( $args->{'ds'}->{$_}->{$type} )
        } keys %{ $args->{'ds'} };
 
        $log->debug("tags = ", join(",", @tags));
diff --git a/run.pl b/run.pl
index d0c4ae5..ae3f131 100755 (executable)
--- a/run.pl
+++ b/run.pl
@@ -65,7 +65,11 @@ my $est = new WebPAC::Output::Estraier(
        database => 'ps',
 );
 
-while (my $row = $isis->fetch) {
+my $total_rows = 0;
+
+for ( 0 ... $isis->size ) {
+
+       my $row = $isis->fetch || next;
 
        my $mfn = $row->{'000'}->[0] || die "can't find MFN";
 
@@ -73,20 +77,20 @@ while (my $row = $isis->fetch) {
 
 #      print STDERR Dumper($row, $ds);
 
-       my $html = $out->apply(
-               template => 'html_ffzg.tt',
-               data => $ds,
-       );
-
-       # create test output
-
-       my $file = sprintf('out/%02d.html', $mfn );
-       open(my $fh, '>', $file) or die "can't open $file: $!";
-       print $fh $html;
-       close($fh);
-
-       $html =~ s#\s*[\n\r]+\s*##gs;
-
+#      my $html = $out->apply(
+#              template => 'html_ffzg.tt',
+#              data => $ds,
+#      );
+#
+#      # create test output
+#
+#      my $file = sprintf('out/%02d.html', $mfn );
+#      open(my $fh, '>', $file) or die "can't open $file: $!";
+#      print $fh $html;
+#      close($fh);
+#
+#      $html =~ s#\s*[\n\r]+\s*##gs;
+#
 #      print STDERR $html;
 
        $est->add(
@@ -95,4 +99,10 @@ while (my $row = $isis->fetch) {
                type => 'search',
        );
 
+       $total_rows++;
+
 };
+
+my $log = $lookup->_get_logger;
+
+$log->info("$total_rows records indexed");