From: Dobrica Pavlinusic Date: Wed, 23 Nov 2005 00:14:05 +0000 (+0000) Subject: r9064@llin: dpavlin | 2005-11-23 01:15:24 +0100 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=044c7d8d6a5df6d271761fdf6b02ef46c03423ca;hp=23dbba3d4e6047e043eed74399f529f84a23b2cb;p=webpac2 r9064@llin: dpavlin | 2005-11-23 01:15:24 +0100 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 --- diff --git a/lib/WebPAC/DB.pm b/lib/WebPAC/DB.pm index bda66cc..f9e58e0 100644 --- a/lib/WebPAC/DB.pm +++ b/lib/WebPAC/DB.pm @@ -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'}); diff --git a/lib/WebPAC/Input/ISIS.pm b/lib/WebPAC/Input/ISIS.pm index b6a05f3..5ab2a76 100644 --- a/lib/WebPAC/Input/ISIS.pm +++ b/lib/WebPAC/Input/ISIS.pm @@ -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 diff --git a/lib/WebPAC/Output/Estraier.pm b/lib/WebPAC/Output/Estraier.pm index 5581abc..871237f 100644 --- a/lib/WebPAC/Output/Estraier.pm +++ b/lib/WebPAC/Output/Estraier.pm @@ -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 --- 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");